Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 219483
b: refs/heads/master
c: d653c0a
h: refs/heads/master
i:
  219481: 4a0bed9
  219479: ca8efa9
v: v3
  • Loading branch information
Jarod Wilson authored and Mauro Carvalho Chehab committed Oct 22, 2010
1 parent 6d06af3 commit bd74e1c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 917167e9a34f7577086ccfcbf07f6fb96a209a31
refs/heads/master: d653c0af49960631770962e30bb0aca67c4631a2
63 changes: 38 additions & 25 deletions trunk/drivers/staging/lirc/lirc_igorplugusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@


/* module identification */
#define DRIVER_VERSION "0.1"
#define DRIVER_VERSION "0.2"
#define DRIVER_AUTHOR \
"Jan M. Hochstein <hochstein@algo.informatik.tu-darmstadt.de>"
#define DRIVER_DESC "Igorplug USB remote driver for LIRC"
Expand Down Expand Up @@ -276,6 +276,25 @@ static void set_use_dec(void *data)
dprintk(DRIVER_NAME "[%d]: set use dec\n", ir->devnum);
}

static void send_fragment(struct igorplug *ir, struct lirc_buffer *buf,
int i, int max)
{
int code;

/* MODE2: pulse/space (PULSE_BIT) in 1us units */
while (i < max) {
/* 1 Igor-tick = 85.333333 us */
code = (unsigned int)ir->buf_in[i] * 85 +
(unsigned int)ir->buf_in[i] / 3;
ir->last_time.tv_usec += code;
if (ir->in_space)
code |= PULSE_BIT;
lirc_buffer_write(buf, (unsigned char *)&code);
/* 1 chunk = CODE_LENGTH bytes */
ir->in_space ^= 1;
++i;
}
}

/**
* Called in user context.
Expand All @@ -299,24 +318,16 @@ static int igorplugusb_remote_poll(void *data, struct lirc_buffer *buf)
ir->buf_in, ir->len_in,
/*timeout*/HZ * USB_CTRL_GET_TIMEOUT);
if (ret > 0) {
int i = DEVICE_HEADERLEN;
int code, timediff;
struct timeval now;

if (ret <= 1) /* ACK packet has 1 byte --> ignore */
/* ACK packet has 1 byte --> ignore */
if (ret < DEVICE_HEADERLEN)
return -ENODATA;

dprintk(DRIVER_NAME ": Got %d bytes. Header: %02x %02x %02x\n",
ret, ir->buf_in[0], ir->buf_in[1], ir->buf_in[2]);

if (ir->buf_in[2] != 0) {
printk(DRIVER_NAME "[%d]: Device buffer overrun.\n",
ir->devnum);
/* start at earliest byte */
i = DEVICE_HEADERLEN + ir->buf_in[2];
/* where are we now? space, gap or pulse? */
}

do_gettimeofday(&now);
timediff = now.tv_sec - ir->last_time.tv_sec;
if (timediff + 1 > PULSE_MASK / 1000000)
Expand All @@ -333,18 +344,20 @@ static int igorplugusb_remote_poll(void *data, struct lirc_buffer *buf)
lirc_buffer_write(buf, (unsigned char *)&code);
ir->in_space = 1; /* next comes a pulse */

/* MODE2: pulse/space (PULSE_BIT) in 1us units */

while (i < ret) {
/* 1 Igor-tick = 85.333333 us */
code = (unsigned int)ir->buf_in[i] * 85
+ (unsigned int)ir->buf_in[i] / 3;
if (ir->in_space)
code |= PULSE_BIT;
lirc_buffer_write(buf, (unsigned char *)&code);
/* 1 chunk = CODE_LENGTH bytes */
ir->in_space ^= 1;
++i;
if (ir->buf_in[2] == 0)
send_fragment(ir, buf, DEVICE_HEADERLEN, ret);
else {
printk(KERN_WARNING DRIVER_NAME
"[%d]: Device buffer overrun.\n", ir->devnum);
/* HHHNNNNNNNNNNNOOOOOOOO H = header
<---[2]---> N = newer
<---------ret--------> O = older */
ir->buf_in[2] %= ret - DEVICE_HEADERLEN; /* sanitize */
/* keep even-ness to not desync pulse/pause */
send_fragment(ir, buf, DEVICE_HEADERLEN +
ir->buf_in[2] - (ir->buf_in[2] & 1), ret);
send_fragment(ir, buf, DEVICE_HEADERLEN,
DEVICE_HEADERLEN + ir->buf_in[2]);
}

ret = usb_control_msg(
Expand Down Expand Up @@ -444,7 +457,7 @@ static int igorplugusb_remote_probe(struct usb_interface *intf,

switch (mem_failure) {
case 9:
usb_free_coherent(dev, DEVICE_BUFLEN+DEVICE_HEADERLEN,
usb_free_coherent(dev, DEVICE_BUFLEN + DEVICE_HEADERLEN,
ir->buf_in, ir->dma_in);
case 3:
kfree(driver);
Expand All @@ -460,7 +473,7 @@ static int igorplugusb_remote_probe(struct usb_interface *intf,
ir->d = driver;
ir->devnum = devnum;
ir->usbdev = dev;
ir->len_in = DEVICE_BUFLEN+DEVICE_HEADERLEN;
ir->len_in = DEVICE_BUFLEN + DEVICE_HEADERLEN;
ir->in_space = 1; /* First mode2 event is a space. */
do_gettimeofday(&ir->last_time);

Expand Down

0 comments on commit bd74e1c

Please sign in to comment.