Lines Matching +full:gpio +full:- +full:ir +full:- +full:receiver
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
5 Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
11 from the Hauppauge windows driver. Older ivtv versions used i2c-algo-bit,
13 CPU on the PVR-150 which handles IR functions (occasional inability to
17 The implementation is very similar to i2c-algo-bit, but there are enough
19 employed by i2c-algo-bit is to use udelay() to implement the timing
28 i2c-algo-bit would be to try to make it follow the same code path.
30 provide a generic benefit to i2c-algo-bit. Therefore consider this
31 an engineering solution -- not pretty, but it works.
50 #include "ivtv-driver.h"
51 #include "ivtv-cards.h"
52 #include "ivtv-gpio.h"
53 #include "ivtv-i2c.h"
54 #include <media/drv-intf/cx25840.h>
129 "gpio",
137 static int get_key_adaptec(struct IR_i2c *ir, enum rc_proto *protocol, in get_key_adaptec() argument
143 i2c_master_send(ir->c, keybuf, 1); in get_key_adaptec()
144 /* poll IR chip */ in get_key_adaptec()
145 if (i2c_master_recv(ir->c, keybuf, sizeof(keybuf)) != sizeof(keybuf)) { in get_key_adaptec()
166 struct i2c_adapter *adap = &itv->i2c_adap; in ivtv_i2c_new_ir()
167 struct IR_i2c_init_data *init_data = &itv->ir_i2c_init_data; in ivtv_i2c_new_ir()
170 /* Only allow one IR receiver to be registered per board */ in ivtv_i2c_new_ir()
171 if (itv->hw_flags & IVTV_HW_IR_ANY) in ivtv_i2c_new_ir()
172 return -1; in ivtv_i2c_new_ir()
174 /* Our default information for ir-kbd-i2c.c to use */ in ivtv_i2c_new_ir()
177 init_data->ir_codes = RC_MAP_AVERMEDIA_CARDBUS; in ivtv_i2c_new_ir()
178 init_data->internal_get_key_func = in ivtv_i2c_new_ir()
180 init_data->type = RC_PROTO_BIT_OTHER; in ivtv_i2c_new_ir()
181 init_data->name = "AVerMedia AVerTV card"; in ivtv_i2c_new_ir()
185 init_data->ir_codes = RC_MAP_HAUPPAUGE; in ivtv_i2c_new_ir()
186 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP; in ivtv_i2c_new_ir()
187 init_data->type = RC_PROTO_BIT_RC5; in ivtv_i2c_new_ir()
188 init_data->name = itv->card_name; in ivtv_i2c_new_ir()
192 init_data->ir_codes = RC_MAP_HAUPPAUGE; in ivtv_i2c_new_ir()
193 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; in ivtv_i2c_new_ir()
194 init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE | in ivtv_i2c_new_ir()
196 init_data->name = itv->card_name; in ivtv_i2c_new_ir()
199 init_data->get_key = get_key_adaptec; in ivtv_i2c_new_ir()
200 init_data->name = itv->card_name; in ivtv_i2c_new_ir()
202 init_data->ir_codes = RC_MAP_EMPTY; in ivtv_i2c_new_ir()
203 init_data->type = RC_PROTO_BIT_UNKNOWN; in ivtv_i2c_new_ir()
212 -1 : 0; in ivtv_i2c_new_ir()
215 /* Instantiate the IR receiver device using probing -- undesirable */
220 * The external IR receiver is at i2c address 0x34. in ivtv_i2c_new_ir_legacy()
221 * The internal IR receiver is at i2c address 0x30. in ivtv_i2c_new_ir_legacy()
231 0x1a, /* Hauppauge IR external - collides with WM8739 */ in ivtv_i2c_new_ir_legacy()
232 0x18, /* Hauppauge IR internal */ in ivtv_i2c_new_ir_legacy()
238 i2c_new_scanned_device(&itv->i2c_adap, &info, addr_list, NULL); in ivtv_i2c_new_ir_legacy()
243 struct i2c_adapter *adap = &itv->i2c_adap; in ivtv_i2c_register()
249 return -ENODEV; in ivtv_i2c_register()
256 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, adap, type, 0, in ivtv_i2c_register()
257 itv->card_i2c->radio); in ivtv_i2c_register()
259 sd->grp_id = 1 << idx; in ivtv_i2c_register()
260 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, adap, type, 0, in ivtv_i2c_register()
261 itv->card_i2c->demod); in ivtv_i2c_register()
263 sd->grp_id = 1 << idx; in ivtv_i2c_register()
264 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, adap, type, 0, in ivtv_i2c_register()
265 itv->card_i2c->tv); in ivtv_i2c_register()
267 sd->grp_id = 1 << idx; in ivtv_i2c_register()
268 return sd ? 0 : -1; in ivtv_i2c_register()
276 return -1; in ivtv_i2c_register()
278 /* It's an I2C device other than an analog tuner or IR chip */ in ivtv_i2c_register()
280 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, in ivtv_i2c_register()
291 pdata.pvr150_workaround = itv->pvr150_workaround; in ivtv_i2c_register()
292 sd = v4l2_i2c_new_subdev_board(&itv->v4l2_dev, adap, in ivtv_i2c_register()
295 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, in ivtv_i2c_register()
299 sd->grp_id = 1 << idx; in ivtv_i2c_register()
300 return sd ? 0 : -1; in ivtv_i2c_register()
308 spin_lock(&itv->v4l2_dev.lock); in ivtv_find_hw()
309 v4l2_device_for_each_subdev(sd, &itv->v4l2_dev) { in ivtv_find_hw()
310 if (sd->grp_id == hw) { in ivtv_find_hw()
315 spin_unlock(&itv->v4l2_dev.lock); in ivtv_find_hw()
392 return -EREMOTEIO; in ivtv_ack()
400 ret = -EREMOTEIO; in ivtv_ack()
405 ret = -EREMOTEIO; in ivtv_ack()
420 return -EREMOTEIO; in ivtv_sendbyte()
426 return -EREMOTEIO; in ivtv_sendbyte()
431 return -EREMOTEIO; in ivtv_sendbyte()
437 return -EREMOTEIO; in ivtv_sendbyte()
458 return -EREMOTEIO; in ivtv_readbyte()
486 return -EREMOTEIO; in ivtv_start()
493 return -EREMOTEIO; in ivtv_start()
518 return -EREMOTEIO; in ivtv_stop()
532 return -EREMOTEIO; in ivtv_stop()
541 int retry, ret = -EREMOTEIO; in ivtv_write()
564 int retry, ret = -EREMOTEIO; in ivtv_read()
572 ret = ivtv_readbyte(itv, &data[i], i == len - 1); in ivtv_read()
591 mutex_lock(&itv->i2c_bus_lock); in ivtv_xfer()
602 mutex_unlock(&itv->i2c_bus_lock); in ivtv_xfer()
617 /* template for our-bit banger */
630 itv->i2c_state |= 0x01; in ivtv_setscl_old()
632 itv->i2c_state &= ~0x01; in ivtv_setscl_old()
636 write_reg(~itv->i2c_state, IVTV_REG_I2C_SETSCL_OFFSET); in ivtv_setscl_old()
644 itv->i2c_state |= 0x01; in ivtv_setsda_old()
646 itv->i2c_state &= ~0x01; in ivtv_setsda_old()
650 write_reg(~itv->i2c_state, IVTV_REG_I2C_SETSDA_OFFSET); in ivtv_setsda_old()
667 /* template for i2c-bit-algo */
670 .algo = NULL, /* set by i2c-algo-bit */
702 return -ENODEV; in init_ivtv_i2c()
704 if (itv->options.newi2c > 0) { in init_ivtv_i2c()
705 itv->i2c_adap = ivtv_i2c_adap_hw_template; in init_ivtv_i2c()
707 itv->i2c_adap = ivtv_i2c_adap_template; in init_ivtv_i2c()
708 itv->i2c_algo = ivtv_i2c_algo_template; in init_ivtv_i2c()
710 itv->i2c_algo.udelay = itv->options.i2c_clock_period / 2; in init_ivtv_i2c()
711 itv->i2c_algo.data = itv; in init_ivtv_i2c()
712 itv->i2c_adap.algo_data = &itv->i2c_algo; in init_ivtv_i2c()
714 sprintf(itv->i2c_adap.name + strlen(itv->i2c_adap.name), " #%d", in init_ivtv_i2c()
715 itv->instance); in init_ivtv_i2c()
716 i2c_set_adapdata(&itv->i2c_adap, &itv->v4l2_dev); in init_ivtv_i2c()
718 itv->i2c_client = ivtv_i2c_client_template; in init_ivtv_i2c()
719 itv->i2c_client.adapter = &itv->i2c_adap; in init_ivtv_i2c()
720 itv->i2c_adap.dev.parent = &itv->pdev->dev; in init_ivtv_i2c()
726 if (itv->options.newi2c > 0) in init_ivtv_i2c()
727 retval = i2c_add_adapter(&itv->i2c_adap); in init_ivtv_i2c()
729 retval = i2c_bit_add_bus(&itv->i2c_adap); in init_ivtv_i2c()
738 i2c_del_adapter(&itv->i2c_adap); in exit_ivtv_i2c()