143
"ir_video", /* IVTV_HW_I2C_IR_RX_AVER */
144
"ir_video", /* IVTV_HW_I2C_IR_RX_HAUP_EXT */
145
"ir_video", /* IVTV_HW_I2C_IR_RX_HAUP_INT */
146
"ir_tx_z8f0811_haup", /* IVTV_HW_Z8F0811_IR_TX_HAUP */
147
"ir_rx_z8f0811_haup", /* IVTV_HW_Z8F0811_IR_RX_HAUP */
148
"ir_video", /* IVTV_HW_I2C_IR_RX_ADAPTEC */
151
static int get_key_adaptec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
153
unsigned char keybuf[4];
156
i2c_master_send(ir->c, keybuf, 1);
158
if (i2c_master_recv(ir->c, keybuf, sizeof(keybuf)) != sizeof(keybuf)) {
163
if (keybuf[2] == 0xff)
166
/* remove repeat bit */
170
*ir_key = keybuf[3] | keybuf[2] << 8 | keybuf[1] << 16 |keybuf[0] << 24;
176
static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
178
struct i2c_board_info info;
179
struct i2c_adapter *adap = &itv->i2c_adap;
180
struct IR_i2c_init_data *init_data = &itv->ir_i2c_init_data;
181
unsigned short addr_list[2] = { addr, I2C_CLIENT_END };
183
/* Only allow one IR transmitter to be registered per board */
184
if (hw & IVTV_HW_IR_TX_ANY) {
185
if (itv->hw_flags & IVTV_HW_IR_TX_ANY)
187
memset(&info, 0, sizeof(struct i2c_board_info));
188
strlcpy(info.type, type, I2C_NAME_SIZE);
189
return i2c_new_probed_device(adap, &info, addr_list, NULL)
193
/* Only allow one IR receiver to be registered per board */
194
if (itv->hw_flags & IVTV_HW_IR_RX_ANY)
197
/* Our default information for ir-kbd-i2c.c to use */
199
case IVTV_HW_I2C_IR_RX_AVER:
200
init_data->ir_codes = RC_MAP_AVERMEDIA_CARDBUS;
201
init_data->internal_get_key_func =
202
IR_KBD_GET_KEY_AVERMEDIA_CARDBUS;
203
init_data->type = RC_TYPE_OTHER;
204
init_data->name = "AVerMedia AVerTV card";
206
case IVTV_HW_I2C_IR_RX_HAUP_EXT:
207
case IVTV_HW_I2C_IR_RX_HAUP_INT:
208
/* Default to old black remote */
209
init_data->ir_codes = RC_MAP_RC5_TV;
210
init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP;
211
init_data->type = RC_TYPE_RC5;
212
init_data->name = itv->card_name;
214
case IVTV_HW_Z8F0811_IR_RX_HAUP:
215
/* Default to grey remote */
216
init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW;
217
init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
218
init_data->type = RC_TYPE_RC5;
219
init_data->name = itv->card_name;
221
case IVTV_HW_I2C_IR_RX_ADAPTEC:
222
init_data->get_key = get_key_adaptec;
223
init_data->name = itv->card_name;
224
/* FIXME: The protocol and RC_MAP needs to be corrected */
225
init_data->ir_codes = RC_MAP_EMPTY;
226
init_data->type = RC_TYPE_UNKNOWN;
230
memset(&info, 0, sizeof(struct i2c_board_info));
231
info.platform_data = init_data;
232
strlcpy(info.type, type, I2C_NAME_SIZE);
234
return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ?
238
/* Instantiate the IR receiver device using probing -- undesirable */
239
struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
241
struct i2c_board_info info;
243
* The external IR receiver is at i2c address 0x34.
244
* The internal IR receiver is at i2c address 0x30.
246
* In theory, both can be fitted, and Hauppauge suggests an external
247
* overrides an internal. That's why we probe 0x1a (~0x34) first. CB
249
* Some of these addresses we probe may collide with other i2c address
250
* allocations, so this function must be called after all other i2c
251
* devices we care about are registered.
253
const unsigned short addr_list[] = {
254
0x1a, /* Hauppauge IR external - collides with WM8739 */
255
0x18, /* Hauppauge IR internal */
259
memset(&info, 0, sizeof(struct i2c_board_info));
260
strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
261
return i2c_new_probed_device(&itv->i2c_adap, &info, addr_list, NULL);
152
264
int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
154
266
struct v4l2_subdev *sd;
155
267
struct i2c_adapter *adap = &itv->i2c_adap;
156
const char *mod = hw_modules[idx];
157
268
const char *type = hw_devicenames[idx];
158
269
u32 hw = 1 << idx;
162
273
if (hw == IVTV_HW_TUNER) {
163
274
/* special tuner handling */
164
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
166
0, itv->card_i2c->radio);
168
sd->grp_id = 1 << idx;
169
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
171
0, itv->card_i2c->demod);
173
sd->grp_id = 1 << idx;
174
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
176
0, itv->card_i2c->tv);
275
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, adap, type, 0,
276
itv->card_i2c->radio);
278
sd->grp_id = 1 << idx;
279
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, adap, type, 0,
280
itv->card_i2c->demod);
282
sd->grp_id = 1 << idx;
283
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, adap, type, 0,
178
286
sd->grp_id = 1 << idx;
179
287
return sd ? 0 : -1;
290
if (hw & IVTV_HW_IR_ANY)
291
return ivtv_i2c_new_ir(itv, hw, type, hw_addrs[idx]);
293
/* Is it not an I2C device or one we do not wish to register? */
181
294
if (!hw_addrs[idx])
297
/* It's an I2C device other than an analog tuner or IR chip */
183
298
if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) {
184
299
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
185
adap, mod, type, 0, I2C_ADDRS(hw_addrs[idx]));
300
adap, type, 0, I2C_ADDRS(hw_addrs[idx]));
301
} else if (hw == IVTV_HW_CX25840) {
302
struct cx25840_platform_data pdata;
303
struct i2c_board_info cx25840_info = {
305
.addr = hw_addrs[idx],
306
.platform_data = &pdata,
309
pdata.pvr150_workaround = itv->pvr150_workaround;
310
sd = v4l2_i2c_new_subdev_board(&itv->v4l2_dev, adap,
311
&cx25840_info, NULL);
187
313
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
188
adap, mod, type, hw_addrs[idx], NULL);
314
adap, type, hw_addrs[idx], NULL);
191
317
sd->grp_id = 1 << idx;
624
751
retval = i2c_bit_add_bus(&itv->i2c_adap);
626
/* Instantiate the IR receiver device, if present */
628
struct i2c_board_info info;
629
/* The external IR receiver is at i2c address 0x34 (0x35 for
630
reads). Future Hauppauge cards will have an internal
631
receiver at 0x30 (0x31 for reads). In theory, both can be
632
fitted, and Hauppauge suggest an external overrides an
635
That's why we probe 0x1a (~0x34) first. CB
637
const unsigned short addr_list[] = {
638
0x1a, /* Hauppauge IR external */
639
0x18, /* Hauppauge IR internal */
640
0x71, /* Hauppauge IR (PVR150) */
641
0x64, /* Pixelview IR */
642
0x30, /* KNC ONE IR */
643
0x6b, /* Adaptec IR */
647
memset(&info, 0, sizeof(struct i2c_board_info));
648
strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
649
i2c_new_probed_device(&itv->i2c_adap, &info, addr_list);