struct IR_rx {
/* RX device */
- struct i2c_client c_rx;
+ struct i2c_client *c;
/* RX device buffer & lock */
struct lirc_buffer buf;
struct IR_tx {
/* TX device */
- struct i2c_client c_tx;
+ struct i2c_client *c;
/* TX additional actions needed */
int need_boot;
## args)
#define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
-#define ZILOG_HAUPPAUGE_IR_RX_NAME "Zilog/Hauppauge IR RX"
-#define ZILOG_HAUPPAUGE_IR_TX_NAME "Zilog/Hauppauge IR TX"
-
/* module parameters */
static int debug; /* debug output */
static int disable_rx; /* disable RX device */
* Send random "poll command" (?) Windows driver does this
* and it is a good point to detect chip failure.
*/
- ret = i2c_master_send(&rx->c_rx, sendbuf, 1);
+ ret = i2c_master_send(rx->c, sendbuf, 1);
if (ret != 1) {
zilog_error("i2c_master_send failed with %d\n", ret);
if (failures >= 3) {
continue;
}
- ret = i2c_master_recv(&rx->c_rx, keybuf, sizeof(keybuf));
+ ret = i2c_master_recv(rx->c, keybuf, sizeof(keybuf));
mutex_unlock(&ir->ir_lock);
if (ret != sizeof(keybuf)) {
zilog_error("i2c_master_recv failed with %d -- "
* must be possible even when the device is open
*/
if (ir->rx != NULL)
- i2c_use_client(&ir->rx->c_rx);
+ i2c_use_client(ir->rx->c);
if (ir->tx != NULL)
- i2c_use_client(&ir->tx->c_tx);
+ i2c_use_client(ir->tx->c);
return 0;
}
struct IR *ir = data;
if (ir->rx)
- i2c_release_client(&ir->rx->c_rx);
+ i2c_release_client(ir->rx->c);
if (ir->tx)
- i2c_release_client(&ir->tx->c_tx);
+ i2c_release_client(ir->tx->c);
if (ir->l.owner != NULL)
module_put(ir->l.owner);
}
buf[1 + j] = data_block[i + j];
dprintk("%02x %02x %02x %02x %02x",
buf[0], buf[1], buf[2], buf[3], buf[4]);
- ret = i2c_master_send(&tx->c_tx, buf, tosend + 1);
+ ret = i2c_master_send(tx->c, buf, tosend + 1);
if (ret != tosend + 1) {
zilog_error("i2c_master_send failed with %d\n", ret);
return ret < 0 ? ret : -EFAULT;
/* kick it off? */
buf[0] = 0x00;
buf[1] = 0x20;
- ret = i2c_master_send(&tx->c_tx, buf, 2);
+ ret = i2c_master_send(tx->c, buf, 2);
if (ret != 2) {
zilog_error("i2c_master_send failed with %d\n", ret);
return ret < 0 ? ret : -EFAULT;
}
- ret = i2c_master_send(&tx->c_tx, buf, 1);
+ ret = i2c_master_send(tx->c, buf, 1);
if (ret != 1) {
zilog_error("i2c_master_send failed with %d\n", ret);
return ret < 0 ? ret : -EFAULT;
}
/* Here comes the firmware version... (hopefully) */
- ret = i2c_master_recv(&tx->c_tx, buf, 4);
+ ret = i2c_master_recv(tx->c, buf, 4);
if (ret != 4) {
zilog_error("i2c_master_recv failed with %d\n", ret);
return 0;
}
/* Request codeset data file */
- ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", &tx->c_tx.dev);
+ ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", &tx->c->dev);
if (ret != 0) {
zilog_error("firmware haup-ir-blaster.bin not available "
"(%d)\n", ret);
/* Send data block length? */
buf[0] = 0x00;
buf[1] = 0x40;
- ret = i2c_master_send(&tx->c_tx, buf, 2);
+ ret = i2c_master_send(tx->c, buf, 2);
if (ret != 2) {
zilog_error("i2c_master_send failed with %d\n", ret);
return ret < 0 ? ret : -EFAULT;
}
- ret = i2c_master_send(&tx->c_tx, buf, 1);
+ ret = i2c_master_send(tx->c, buf, 1);
if (ret != 1) {
zilog_error("i2c_master_send failed with %d\n", ret);
return ret < 0 ? ret : -EFAULT;
}
/* Send finished download? */
- ret = i2c_master_recv(&tx->c_tx, buf, 1);
+ ret = i2c_master_recv(tx->c, buf, 1);
if (ret != 1) {
zilog_error("i2c_master_recv failed with %d\n", ret);
return ret < 0 ? ret : -EFAULT;
/* Send prepare command? */
buf[0] = 0x00;
buf[1] = 0x80;
- ret = i2c_master_send(&tx->c_tx, buf, 2);
+ ret = i2c_master_send(tx->c, buf, 2);
if (ret != 2) {
zilog_error("i2c_master_send failed with %d\n", ret);
return ret < 0 ? ret : -EFAULT;
for (i = 0; i < 20; ++i) {
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((50 * HZ + 999) / 1000);
- ret = i2c_master_send(&tx->c_tx, buf, 1);
+ ret = i2c_master_send(tx->c, buf, 1);
if (ret == 1)
break;
dprintk("NAK expected: i2c_master_send "
}
/* Seems to be an 'ok' response */
- i = i2c_master_recv(&tx->c_tx, buf, 1);
+ i = i2c_master_recv(tx->c, buf, 1);
if (i != 1) {
zilog_error("i2c_master_recv failed with %d\n", ret);
return -EFAULT;
{
struct IR *ir = NULL;
struct i2c_adapter *adap = client->adapter;
- char buf;
int ret;
int have_rx = 0, have_tx = 0;
* The external IR receiver is at i2c address 0x71.
* The IR transmitter is at 0x70.
*/
- client->addr = 0x70;
- if (i2c_master_recv(client, &buf, 1) == 1)
+ if (id->driver_data & ID_FLAG_TX) {
have_tx = 1;
- dprintk("probe 0x70 @ %s: %s\n",
- adap->name, have_tx ? "success" : "failed");
-
- if (!disable_rx) {
- client->addr = 0x71;
- if (i2c_master_recv(client, &buf, 1) == 1)
- have_rx = 1;
- dprintk("probe 0x71 @ %s: %s\n",
- adap->name, have_rx ? "success" : "failed");
- }
-
- if (!(have_rx || have_tx)) {
- zilog_error("%s: no devices found\n", adap->name);
- goto out_nodev;
+ } else if (!disable_rx) {
+ have_rx = 1;
+ } else {
+ return -ENXIO;
}
printk(KERN_INFO "lirc_zilog: chip found with %s\n",
if (have_tx) {
ir->tx = kzalloc(sizeof(struct IR_tx), GFP_KERNEL);
if (ir->tx != NULL) {
+ ir->tx->c = client;
ir->tx->need_boot = 1;
ir->tx->post_tx_ready_poll =
(id->driver_data & ID_FLAG_HDPVR) ? false : true;
if (ir->rx == NULL) {
ret = -ENOMEM;
} else {
+ ir->rx->c = client;
ir->rx->hdpvr_data_fmt =
(id->driver_data & ID_FLAG_HDPVR) ? true : false;
mutex_init(&ir->rx->buf_lock);
/* initialise RX device */
if (ir->rx != NULL) {
DECLARE_COMPLETION(tn);
- memcpy(&ir->rx->c_rx, client, sizeof(struct i2c_client));
-
- ir->rx->c_rx.addr = 0x71;
- strlcpy(ir->rx->c_rx.name, ZILOG_HAUPPAUGE_IR_RX_NAME,
- I2C_NAME_SIZE);
/* try to fire up polling thread */
ir->rx->t_notify = &tn;
ir->rx->t_notify = NULL;
}
- /* initialise TX device */
- if (ir->tx) {
- memcpy(&ir->tx->c_tx, client, sizeof(struct i2c_client));
- ir->tx->c_tx.addr = 0x70;
- strlcpy(ir->tx->c_tx.name, ZILOG_HAUPPAUGE_IR_TX_NAME,
- I2C_NAME_SIZE);
- }
-
/* set lirc_dev stuff */
ir->l.code_length = 13;
ir->l.rbuf = (ir->rx == NULL) ? NULL : &ir->rx->buf;
/* FIXME - memory deallocation for all error cases needs work */
/* undo everything, hopefully... */
if (ir->rx != NULL)
- ir_remove(&ir->rx->c_rx);
+ ir_remove(ir->rx->c);
if (ir->tx != NULL)
- ir_remove(&ir->tx->c_tx);
+ ir_remove(ir->tx->c);
return ret;
-out_nodev:
- /* FIXME - memory deallocation for all error cases needs work */
- zilog_error("no device found\n");
- return -ENODEV;
-
out_nomem:
/* FIXME - memory deallocation for all error cases needs work */
zilog_error("memory allocation failure\n");