/* IR */ static int tt3650_rc_query(struct dvb_usb_device *d) { int ret; u8 rx[9]; /* A CMD_GET_IR_CODE reply is 9 bytes long */ struct ttusb2_state *st = d->priv; ret = ttusb2_msg(d, CMD_GET_IR_CODE, NULL, 0, rx, sizeof(rx)); if (ret != 0) return ret; if (rx[8] & 0x01) { /* got a "press" event */ st->last_rc_key = (rx[3] << 8) | rx[2]; deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]); rc_keydown(d->rc_dev, st->last_rc_key, 0); } else if (st->last_rc_key) { rc_keyup(d->rc_dev); st->last_rc_key = 0; } return 0; }
static int ttusb2_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) { struct dvb_usb_device *d = i2c_get_adapdata(adap); static u8 obuf[60], ibuf[60]; int i,read; if (mutex_lock_interruptible(&d->i2c_mutex) < 0) return -EAGAIN; if (num > 2) warn("more than 2 i2c messages at a time is not handled yet. TODO."); for (i = 0; i < num; i++) { read = i+1 < num && (msg[i+1].flags & I2C_M_RD); obuf[0] = (msg[i].addr << 1) | read; obuf[1] = msg[i].len; /* read request */ if (read) obuf[2] = msg[i+1].len; else obuf[2] = 0; memcpy(&obuf[3],msg[i].buf,msg[i].len); if (ttusb2_msg(d, CMD_I2C_XFER, obuf, msg[i].len+3, ibuf, obuf[2] + 3) < 0) { err("i2c transfer failed."); break; } if (read) { memcpy(msg[i+1].buf,&ibuf[3],msg[i+1].len); i++; } } mutex_unlock(&d->i2c_mutex); return i; }
static int ttusb2_power_ctrl(struct dvb_usb_device *d, int onoff) { u8 b = onoff; ttusb2_msg(d, CMD_POWER, &b, 0, NULL, 0); return ttusb2_msg(d, CMD_POWER, &b, 1, NULL, 0); }