staticint au0828_get_key_au8522(struct au0828_rc *ir)
{ unsignedchar buf[40]; struct ir_raw_event rawir = {}; int i, j, rc; int prv_bit, bit, width; bool first = true;
/* do nothing if device is disconnected */ if (test_bit(DEV_DISCONNECTED, &ir->dev->dev_state)) return 0;
/* Check IR int */
rc = au8522_rc_read(ir, 0xe1, -1, buf, 1); if (rc < 0 || !(buf[0] & (1 << 4))) { /* Be sure that IR is enabled */
au8522_rc_set(ir, 0xe0, 1 << 4); return 0;
}
/* Something arrived. Get the data */
rc = au8522_rc_read(ir, 0xe3, 0x11, buf, sizeof(buf));
if (rc < 0) return rc;
/* Disable IR */
au8522_rc_clear(ir, 0xe0, 1 << 4);
/* Enable IR */
au8522_rc_set(ir, 0xe0, 1 << 4);
dprintk(16, "RC data received: %*ph\n", 40, buf);
prv_bit = (buf[0] >> 7) & 0x01;
width = 0; for (i = 0; i < sizeof(buf); i++) { for (j = 7; j >= 0; j--) {
bit = (buf[i] >> j) & 0x01; if (bit == prv_bit) {
width++; continue;
}
/* * Fix an au8522 bug: the first pulse event * is lost. So, we need to fake it, based on the * protocol. That means that not all raw decoders * will work, as we need to add a hack for each * protocol, based on the first space. * So, we only support RC5 and NEC.
*/
/* do nothing if device is disconnected */ if (!test_bit(DEV_DISCONNECTED, &ir->dev->dev_state)) { /* Disable IR */
au8522_rc_clear(ir, 0xe0, 1 << 4);
}
}
staticint au0828_probe_i2c_ir(struct au0828_dev *dev)
{ int i = 0; staticconstunsignedshort addr_list[] = {
0x47, I2C_CLIENT_END
};
while (addr_list[i] != I2C_CLIENT_END) { if (i2c_probe_func_quick_read(dev->i2c_client.adapter,
addr_list[i]) == 1) return addr_list[i];
i++;
}
return -ENODEV;
}
int au0828_rc_register(struct au0828_dev *dev)
{ struct au0828_rc *ir; struct rc_dev *rc; int err = -ENOMEM;
u16 i2c_rc_dev_addr = 0;
if (!dev->board.has_ir_i2c || disable_ir) return 0;
i2c_rc_dev_addr = au0828_probe_i2c_ir(dev); if (!i2c_rc_dev_addr) return -ENODEV;
ir = kzalloc(sizeof(*ir), GFP_KERNEL);
rc = rc_allocate_device(RC_DRIVER_IR_RAW); if (!ir || !rc) goto error;
/* record handles to ourself */
ir->dev = dev;
dev->ir = ir;
ir->rc = rc;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.