[media] rc: do not wake up rc thread unless there is something to do
The TechnoTrend USB IR Receiver sends 125 ISO URBs per second, even when
there is no IR activity. Reduce the number of wake ups from the other
drivers too.
This saves about 0.25ms/s on a 2.4GHz Core 2 according to powertop.
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index 71f03ac..1aee57f 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -121,8 +121,9 @@
*/
static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)
{
+ struct ir_raw_event rawir;
unsigned i, v, b;
- DEFINE_IR_RAW_EVENT(rawir);
+ bool event = false;
init_ir_raw_event(&rawir);
@@ -132,12 +133,14 @@
case 0xfe:
rawir.pulse = false;
rawir.duration = NS_PER_BYTE;
- ir_raw_event_store_with_filter(tt->rc, &rawir);
+ if (ir_raw_event_store_with_filter(tt->rc, &rawir))
+ event = true;
break;
case 0:
rawir.pulse = true;
rawir.duration = NS_PER_BYTE;
- ir_raw_event_store_with_filter(tt->rc, &rawir);
+ if (ir_raw_event_store_with_filter(tt->rc, &rawir))
+ event = true;
break;
default:
/* one edge per byte */
@@ -150,16 +153,20 @@
}
rawir.duration = NS_PER_BIT * (8 - b);
- ir_raw_event_store_with_filter(tt->rc, &rawir);
+ if (ir_raw_event_store_with_filter(tt->rc, &rawir))
+ event = true;
rawir.pulse = !rawir.pulse;
rawir.duration = NS_PER_BIT * b;
- ir_raw_event_store_with_filter(tt->rc, &rawir);
+ if (ir_raw_event_store_with_filter(tt->rc, &rawir))
+ event = true;
break;
}
}
- ir_raw_event_handle(tt->rc);
+ /* don't wakeup when there's nothing to do */
+ if (event)
+ ir_raw_event_handle(tt->rc);
}
static void ttusbir_urb_complete(struct urb *urb)