forked from Minki/linux
[media] redrat3: fix timeout handling
The redrat3 sends an usb packet to the host either when the minimum pause or the timeout occurs, so we can always add a trailing space in our processing. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
parent
14d8188aab
commit
25da661a14
@ -188,8 +188,7 @@ struct redrat3_dev {
|
|||||||
/* usb dma */
|
/* usb dma */
|
||||||
dma_addr_t dma_in;
|
dma_addr_t dma_in;
|
||||||
|
|
||||||
/* rx signal timeout timer */
|
/* rx signal timeout */
|
||||||
struct timer_list rx_timeout;
|
|
||||||
u32 hw_timeout;
|
u32 hw_timeout;
|
||||||
|
|
||||||
/* Is the device currently transmitting?*/
|
/* Is the device currently transmitting?*/
|
||||||
@ -330,22 +329,11 @@ static u32 redrat3_us_to_len(u32 microsec)
|
|||||||
return result ? result : 1;
|
return result ? result : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* timer callback to send reset event */
|
|
||||||
static void redrat3_rx_timeout(unsigned long data)
|
|
||||||
{
|
|
||||||
struct redrat3_dev *rr3 = (struct redrat3_dev *)data;
|
|
||||||
|
|
||||||
dev_dbg(rr3->dev, "calling ir_raw_event_reset\n");
|
|
||||||
ir_raw_event_reset(rr3->rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void redrat3_process_ir_data(struct redrat3_dev *rr3)
|
static void redrat3_process_ir_data(struct redrat3_dev *rr3)
|
||||||
{
|
{
|
||||||
DEFINE_IR_RAW_EVENT(rawir);
|
DEFINE_IR_RAW_EVENT(rawir);
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
unsigned i, trailer = 0;
|
unsigned int i, sig_size, single_len, offset, val;
|
||||||
unsigned sig_size, single_len, offset, val;
|
|
||||||
unsigned long delay;
|
|
||||||
u32 mod_freq;
|
u32 mod_freq;
|
||||||
|
|
||||||
if (!rr3) {
|
if (!rr3) {
|
||||||
@ -355,10 +343,6 @@ static void redrat3_process_ir_data(struct redrat3_dev *rr3)
|
|||||||
|
|
||||||
dev = rr3->dev;
|
dev = rr3->dev;
|
||||||
|
|
||||||
/* Make sure we reset the IR kfifo after a bit of inactivity */
|
|
||||||
delay = usecs_to_jiffies(rr3->hw_timeout);
|
|
||||||
mod_timer(&rr3->rx_timeout, jiffies + delay);
|
|
||||||
|
|
||||||
mod_freq = redrat3_val_to_mod_freq(&rr3->irdata);
|
mod_freq = redrat3_val_to_mod_freq(&rr3->irdata);
|
||||||
dev_dbg(dev, "Got mod_freq of %u\n", mod_freq);
|
dev_dbg(dev, "Got mod_freq of %u\n", mod_freq);
|
||||||
|
|
||||||
@ -376,9 +360,6 @@ static void redrat3_process_ir_data(struct redrat3_dev *rr3)
|
|||||||
rawir.pulse = true;
|
rawir.pulse = true;
|
||||||
|
|
||||||
rawir.duration = US_TO_NS(single_len);
|
rawir.duration = US_TO_NS(single_len);
|
||||||
/* Save initial pulse length to fudge trailer */
|
|
||||||
if (i == 0)
|
|
||||||
trailer = rawir.duration;
|
|
||||||
/* cap the value to IR_MAX_DURATION */
|
/* cap the value to IR_MAX_DURATION */
|
||||||
rawir.duration = (rawir.duration > IR_MAX_DURATION) ?
|
rawir.duration = (rawir.duration > IR_MAX_DURATION) ?
|
||||||
IR_MAX_DURATION : rawir.duration;
|
IR_MAX_DURATION : rawir.duration;
|
||||||
@ -388,18 +369,13 @@ static void redrat3_process_ir_data(struct redrat3_dev *rr3)
|
|||||||
ir_raw_event_store_with_filter(rr3->rc, &rawir);
|
ir_raw_event_store_with_filter(rr3->rc, &rawir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add a trailing space, if need be */
|
/* add a trailing space */
|
||||||
if (i % 2) {
|
rawir.pulse = false;
|
||||||
rawir.pulse = false;
|
rawir.timeout = true;
|
||||||
/* this duration is made up, and may not be ideal... */
|
rawir.duration = US_TO_NS(rr3->hw_timeout);
|
||||||
if (trailer < US_TO_NS(1000))
|
dev_dbg(dev, "storing trailing timeout with duration %d\n",
|
||||||
rawir.duration = US_TO_NS(2800);
|
rawir.duration);
|
||||||
else
|
ir_raw_event_store_with_filter(rr3->rc, &rawir);
|
||||||
rawir.duration = trailer;
|
|
||||||
dev_dbg(dev, "storing trailing space with duration %d\n",
|
|
||||||
rawir.duration);
|
|
||||||
ir_raw_event_store_with_filter(rr3->rc, &rawir);
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_dbg(dev, "calling ir_raw_event_handle\n");
|
dev_dbg(dev, "calling ir_raw_event_handle\n");
|
||||||
ir_raw_event_handle(rr3->rc);
|
ir_raw_event_handle(rr3->rc);
|
||||||
@ -880,7 +856,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
|
|||||||
rc->priv = rr3;
|
rc->priv = rr3;
|
||||||
rc->driver_type = RC_DRIVER_IR_RAW;
|
rc->driver_type = RC_DRIVER_IR_RAW;
|
||||||
rc->allowed_protocols = RC_BIT_ALL;
|
rc->allowed_protocols = RC_BIT_ALL;
|
||||||
rc->timeout = US_TO_NS(2750);
|
rc->timeout = US_TO_NS(rr3->hw_timeout);
|
||||||
rc->tx_ir = redrat3_transmit_ir;
|
rc->tx_ir = redrat3_transmit_ir;
|
||||||
rc->s_tx_carrier = redrat3_set_tx_carrier;
|
rc->s_tx_carrier = redrat3_set_tx_carrier;
|
||||||
rc->driver_name = DRIVER_NAME;
|
rc->driver_name = DRIVER_NAME;
|
||||||
@ -990,7 +966,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
|
|||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* store current hardware timeout, in us, will use for kfifo resets */
|
/* store current hardware timeout, in µs */
|
||||||
rr3->hw_timeout = redrat3_get_timeout(rr3);
|
rr3->hw_timeout = redrat3_get_timeout(rr3);
|
||||||
|
|
||||||
/* default.. will get overridden by any sends with a freq defined */
|
/* default.. will get overridden by any sends with a freq defined */
|
||||||
@ -1026,7 +1002,6 @@ static int redrat3_dev_probe(struct usb_interface *intf,
|
|||||||
retval = -ENOMEM;
|
retval = -ENOMEM;
|
||||||
goto led_free_error;
|
goto led_free_error;
|
||||||
}
|
}
|
||||||
setup_timer(&rr3->rx_timeout, redrat3_rx_timeout, (unsigned long)rr3);
|
|
||||||
|
|
||||||
/* we can register the device now, as it is ready */
|
/* we can register the device now, as it is ready */
|
||||||
usb_set_intfdata(intf, rr3);
|
usb_set_intfdata(intf, rr3);
|
||||||
@ -1055,7 +1030,6 @@ static void redrat3_dev_disconnect(struct usb_interface *intf)
|
|||||||
usb_set_intfdata(intf, NULL);
|
usb_set_intfdata(intf, NULL);
|
||||||
rc_unregister_device(rr3->rc);
|
rc_unregister_device(rr3->rc);
|
||||||
led_classdev_unregister(&rr3->led);
|
led_classdev_unregister(&rr3->led);
|
||||||
del_timer_sync(&rr3->rx_timeout);
|
|
||||||
redrat3_delete(rr3, udev);
|
redrat3_delete(rr3, udev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user