Lines Matching refs:ir
59 static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol, in get_key_haup_common() argument
66 if (size != i2c_master_recv(ir->c, buf, size)) in get_key_haup_common()
96 dev_dbg(&ir->rc->dev, in get_key_haup_common()
114 dev_dbg(&ir->rc->dev, in get_key_haup_common()
120 dev_dbg(&ir->rc->dev, in get_key_haup_common()
133 static int get_key_haup(struct IR_i2c *ir, enum rc_proto *protocol, in get_key_haup() argument
136 return get_key_haup_common(ir, protocol, scancode, toggle, 3); in get_key_haup()
139 static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_proto *protocol, in get_key_haup_xvr() argument
151 ret = i2c_master_send(ir->c, buf, 1); in get_key_haup_xvr()
155 return get_key_haup_common(ir, protocol, scancode, toggle, 6); in get_key_haup_xvr()
158 static int get_key_pixelview(struct IR_i2c *ir, enum rc_proto *protocol, in get_key_pixelview() argument
165 rc = i2c_master_recv(ir->c, &b, 1); in get_key_pixelview()
167 dev_dbg(&ir->rc->dev, "read error\n"); in get_key_pixelview()
179 static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_proto *protocol, in get_key_fusionhdtv() argument
186 rc = i2c_master_recv(ir->c, buf, 4); in get_key_fusionhdtv()
188 dev_dbg(&ir->rc->dev, "read error\n"); in get_key_fusionhdtv()
195 dev_dbg(&ir->rc->dev, "%s: %*ph\n", __func__, 4, buf); in get_key_fusionhdtv()
207 static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol, in get_key_knc1() argument
214 rc = i2c_master_recv(ir->c, &b, 1); in get_key_knc1()
216 dev_dbg(&ir->rc->dev, "read error\n"); in get_key_knc1()
226 dev_dbg(&ir->rc->dev, "key %02x\n", b); in get_key_knc1()
241 static int get_key_geniatech(struct IR_i2c *ir, enum rc_proto *protocol, in get_key_geniatech() argument
249 rc = i2c_master_recv(ir->c, &b, 1); in get_key_geniatech()
255 dev_dbg(&ir->rc->dev, "read error\n"); in get_key_geniatech()
262 if (ir->old == b) in get_key_geniatech()
264 ir->old = b; in get_key_geniatech()
270 dev_dbg(&ir->rc->dev, "key %02x\n", b); in get_key_geniatech()
274 *toggle = ir->old >> 7; in get_key_geniatech()
278 static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_proto *protocol, in get_key_avermedia_cardbus() argument
282 struct i2c_msg msg[] = { { .addr = ir->c->addr, .flags = 0, in get_key_avermedia_cardbus()
284 { .addr = ir->c->addr, .flags = I2C_M_RD, in get_key_avermedia_cardbus()
287 if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { in get_key_avermedia_cardbus()
288 dev_dbg(&ir->rc->dev, "read error\n"); in get_key_avermedia_cardbus()
297 if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { in get_key_avermedia_cardbus()
298 dev_dbg(&ir->rc->dev, "read error\n"); in get_key_avermedia_cardbus()
305 dev_dbg(&ir->rc->dev, "read key 0x%02x/0x%02x\n", key, keygroup); in get_key_avermedia_cardbus()
307 dev_warn(&ir->rc->dev, "warning: invalid key group 0x%02x for key 0x%02x\n", in get_key_avermedia_cardbus()
314 if (ir->c->addr == 0x41) /* AVerMedia EM78P153 */ in get_key_avermedia_cardbus()
322 static int ir_key_poll(struct IR_i2c *ir) in ir_key_poll() argument
329 dev_dbg(&ir->rc->dev, "%s\n", __func__); in ir_key_poll()
330 rc = ir->get_key(ir, &protocol, &scancode, &toggle); in ir_key_poll()
332 dev_warn(&ir->rc->dev, "error %d\n", rc); in ir_key_poll()
337 dev_dbg(&ir->rc->dev, "%s: proto = 0x%04x, scancode = 0x%08x\n", in ir_key_poll()
339 rc_keydown(ir->rc, protocol, scancode, toggle); in ir_key_poll()
347 struct IR_i2c *ir = container_of(work, struct IR_i2c, work.work); in ir_work() local
353 if (mutex_trylock(&ir->lock)) { in ir_work()
354 rc = ir_key_poll(ir); in ir_work()
355 mutex_unlock(&ir->lock); in ir_work()
357 rc_unregister_device(ir->rc); in ir_work()
358 ir->rc = NULL; in ir_work()
363 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling_interval)); in ir_work()
368 struct IR_i2c *ir = dev->priv; in ir_open() local
370 schedule_delayed_work(&ir->work, 0); in ir_open()
377 struct IR_i2c *ir = dev->priv; in ir_close() local
379 cancel_delayed_work_sync(&ir->work); in ir_close()
410 static int send_data_block(struct IR_i2c *ir, int cmd, in send_data_block() argument
430 dev_dbg(&ir->rc->dev, "%*ph", tosend + 1, buf); in send_data_block()
431 ret = i2c_master_send(ir->tx_c, buf, tosend + 1); in send_data_block()
433 dev_dbg(&ir->rc->dev, in send_data_block()
442 ret = i2c_master_send(ir->tx_c, buf, 2); in send_data_block()
444 dev_err(&ir->rc->dev, "i2c_master_send failed with %d\n", ret); in send_data_block()
450 ret = i2c_master_send(ir->tx_c, buf, 1); in send_data_block()
452 dev_err(&ir->rc->dev, "i2c_master_send failed with %d\n", ret); in send_data_block()
459 static int zilog_init(struct IR_i2c *ir) in zilog_init() argument
467 ret = send_data_block(ir, ZILOG_INIT_END, &code_block); in zilog_init()
471 ret = i2c_master_recv(ir->tx_c, buf, 4); in zilog_init()
473 dev_err(&ir->c->dev, "failed to retrieve firmware version: %d\n", in zilog_init()
478 dev_info(&ir->c->dev, "Zilog/Hauppauge IR blaster firmware version %d.%d.%d\n", in zilog_init()
536 struct IR_i2c *ir = rcdev->priv; in zilog_ir_format() local
542 ir->duty_cycle * XTAL_FREQ / 1000, ir->carrier); in zilog_ir_format()
544 (100 - ir->duty_cycle) * XTAL_FREQ / 1000, ir->carrier); in zilog_ir_format()
647 struct IR_i2c *ir = rcdev->priv; in zilog_tx() local
656 ret = mutex_lock_interruptible(&ir->lock); in zilog_tx()
660 ret = send_data_block(ir, ZILOG_UIR_END, &code_block); in zilog_tx()
664 ret = i2c_master_recv(ir->tx_c, buf, 1); in zilog_tx()
666 dev_err(&ir->rc->dev, "i2c_master_recv failed with %d\n", ret); in zilog_tx()
670 dev_dbg(&ir->rc->dev, "code set status: %02x\n", buf[0]); in zilog_tx()
673 dev_err(&ir->rc->dev, "unexpected IR TX response %02x\n", in zilog_tx()
682 ret = i2c_master_send(ir->tx_c, buf, 2); in zilog_tx()
684 dev_err(&ir->rc->dev, "i2c_master_send failed with %d\n", ret); in zilog_tx()
690 dev_dbg(&ir->rc->dev, "send command sent\n"); in zilog_tx()
701 ret = i2c_master_send(ir->tx_c, buf, 1); in zilog_tx()
704 dev_dbg(&ir->rc->dev, in zilog_tx()
710 dev_err(&ir->rc->dev, in zilog_tx()
718 ret = i2c_master_recv(ir->tx_c, buf, 1); in zilog_tx()
720 dev_err(&ir->rc->dev, "i2c_master_recv failed with %d\n", ret); in zilog_tx()
724 dev_err(&ir->rc->dev, "unexpected IR TX response #2: %02x\n", in zilog_tx()
729 dev_dbg(&ir->rc->dev, "transmit complete\n"); in zilog_tx()
734 mutex_unlock(&ir->lock); in zilog_tx()
741 struct IR_i2c *ir = dev->priv; in zilog_tx_carrier() local
746 ir->carrier = carrier; in zilog_tx_carrier()
753 struct IR_i2c *ir = dev->priv; in zilog_tx_duty_cycle() local
755 ir->duty_cycle = duty_cycle; in zilog_tx_duty_cycle()
765 struct IR_i2c *ir; in ir_probe() local
777 ir = devm_kzalloc(&client->dev, sizeof(*ir), GFP_KERNEL); in ir_probe()
778 if (!ir) in ir_probe()
781 ir->c = client; in ir_probe()
782 ir->polling_interval = DEFAULT_POLLING_INTERVAL; in ir_probe()
783 i2c_set_clientdata(client, ir); in ir_probe()
788 ir->get_key = get_key_pixelview; in ir_probe()
796 ir->get_key = get_key_haup; in ir_probe()
802 ir->get_key = get_key_knc1; in ir_probe()
808 ir->get_key = get_key_geniatech; in ir_probe()
811 ir->old = 0xfc; in ir_probe()
815 ir->get_key = get_key_fusionhdtv; in ir_probe()
821 ir->get_key = get_key_avermedia_cardbus; in ir_probe()
827 ir->get_key = get_key_avermedia_cardbus; in ir_probe()
834 ir->get_key = get_key_haup_xvr; in ir_probe()
838 ir->polling_interval = 125; in ir_probe()
856 ir->polling_interval = init_data->polling_interval; in ir_probe()
861 ir->get_key = init_data->get_key; in ir_probe()
864 ir->get_key = get_key_pixelview; in ir_probe()
867 ir->get_key = get_key_haup; in ir_probe()
870 ir->get_key = get_key_knc1; in ir_probe()
873 ir->get_key = get_key_geniatech; in ir_probe()
876 ir->get_key = get_key_fusionhdtv; in ir_probe()
879 ir->get_key = get_key_haup_xvr; in ir_probe()
882 ir->get_key = get_key_avermedia_cardbus; in ir_probe()
896 ir->rc = rc; in ir_probe()
899 if (!name || !ir->get_key || !rc_proto || !ir_codes) { in ir_probe()
906 ir->ir_codes = ir_codes; in ir_probe()
908 snprintf(ir->phys, sizeof(ir->phys), "%s/%s", dev_name(&adap->dev), in ir_probe()
916 rc->input_phys = ir->phys; in ir_probe()
919 rc->priv = ir; in ir_probe()
926 rc->map_name = ir->ir_codes; in ir_probe()
931 mutex_init(&ir->lock); in ir_probe()
933 INIT_DELAYED_WORK(&ir->work, ir_work); in ir_probe()
936 ir->tx_c = i2c_new_dummy_device(client->adapter, 0x70); in ir_probe()
937 if (IS_ERR(ir->tx_c)) { in ir_probe()
939 err = PTR_ERR(ir->tx_c); in ir_probe()
941 } else if (!zilog_init(ir)) { in ir_probe()
942 ir->carrier = 38000; in ir_probe()
943 ir->duty_cycle = 40; in ir_probe()
957 if (!IS_ERR(ir->tx_c)) in ir_probe()
958 i2c_unregister_device(ir->tx_c); in ir_probe()
967 struct IR_i2c *ir = i2c_get_clientdata(client); in ir_remove() local
969 cancel_delayed_work_sync(&ir->work); in ir_remove()
971 i2c_unregister_device(ir->tx_c); in ir_remove()
973 rc_unregister_device(ir->rc); in ir_remove()