Commit b83bfd1b authored by Sean Young's avatar Sean Young Committed by Mauro Carvalho Chehab

[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: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 0938069f
...@@ -295,6 +295,7 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek) ...@@ -295,6 +295,7 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
{ {
DEFINE_IR_RAW_EVENT(rawir); DEFINE_IR_RAW_EVENT(rawir);
u8 sample; u8 sample;
bool event = false;
int i; int i;
for (i = 0; i < fintek->pkts; i++) { for (i = 0; i < fintek->pkts; i++) {
...@@ -332,7 +333,9 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek) ...@@ -332,7 +333,9 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
fit_dbg("Storing %s with duration %d", fit_dbg("Storing %s with duration %d",
rawir.pulse ? "pulse" : "space", rawir.pulse ? "pulse" : "space",
rawir.duration); rawir.duration);
ir_raw_event_store_with_filter(fintek->rdev, &rawir); if (ir_raw_event_store_with_filter(fintek->rdev,
&rawir))
event = true;
break; break;
} }
...@@ -342,8 +345,10 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek) ...@@ -342,8 +345,10 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
fintek->pkts = 0; fintek->pkts = 0;
if (event) {
fit_dbg("Calling ir_raw_event_handle"); fit_dbg("Calling ir_raw_event_handle");
ir_raw_event_handle(fintek->rdev); ir_raw_event_handle(fintek->rdev);
}
} }
/* copy data from hardware rx register into driver buffer */ /* copy data from hardware rx register into driver buffer */
......
...@@ -134,6 +134,7 @@ static void process_ir_data(struct iguanair *ir, unsigned len) ...@@ -134,6 +134,7 @@ static void process_ir_data(struct iguanair *ir, unsigned len)
} else if (len >= 7) { } else if (len >= 7) {
DEFINE_IR_RAW_EVENT(rawir); DEFINE_IR_RAW_EVENT(rawir);
unsigned i; unsigned i;
bool event = false;
init_ir_raw_event(&rawir); init_ir_raw_event(&rawir);
...@@ -147,9 +148,11 @@ static void process_ir_data(struct iguanair *ir, unsigned len) ...@@ -147,9 +148,11 @@ static void process_ir_data(struct iguanair *ir, unsigned len)
RX_RESOLUTION; RX_RESOLUTION;
} }
ir_raw_event_store_with_filter(ir->rc, &rawir); if (ir_raw_event_store_with_filter(ir->rc, &rawir))
event = true;
} }
if (event)
ir_raw_event_handle(ir->rc); ir_raw_event_handle(ir->rc);
} }
} }
......
...@@ -157,7 +157,9 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store_edge); ...@@ -157,7 +157,9 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);
* This routine (which may be called from an interrupt context) works * This routine (which may be called from an interrupt context) works
* in similar manner to ir_raw_event_store_edge. * in similar manner to ir_raw_event_store_edge.
* This routine is intended for devices with limited internal buffer * This routine is intended for devices with limited internal buffer
* It automerges samples of same type, and handles timeouts * It automerges samples of same type, and handles timeouts. Returns non-zero
* if the event was added, and zero if the event was ignored due to idle
* processing.
*/ */
int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev) int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev)
{ {
...@@ -184,7 +186,7 @@ int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev) ...@@ -184,7 +186,7 @@ int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev)
dev->raw->this_ev.duration >= dev->timeout) dev->raw->this_ev.duration >= dev->timeout)
ir_raw_event_set_idle(dev, true); ir_raw_event_set_idle(dev, true);
return 0; return 1;
} }
EXPORT_SYMBOL_GPL(ir_raw_event_store_with_filter); EXPORT_SYMBOL_GPL(ir_raw_event_store_with_filter);
......
...@@ -974,6 +974,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index) ...@@ -974,6 +974,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index)
static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
{ {
DEFINE_IR_RAW_EVENT(rawir); DEFINE_IR_RAW_EVENT(rawir);
bool event = false;
int i = 0; int i = 0;
/* skip meaningless 0xb1 0x60 header bytes on orig receiver */ /* skip meaningless 0xb1 0x60 header bytes on orig receiver */
...@@ -1004,7 +1005,8 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) ...@@ -1004,7 +1005,8 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
rawir.pulse ? "pulse" : "space", rawir.pulse ? "pulse" : "space",
rawir.duration); rawir.duration);
ir_raw_event_store_with_filter(ir->rc, &rawir); if (ir_raw_event_store_with_filter(ir->rc, &rawir))
event = true;
break; break;
case CMD_DATA: case CMD_DATA:
ir->rem--; ir->rem--;
...@@ -1032,8 +1034,10 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) ...@@ -1032,8 +1034,10 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
if (ir->parser_state != CMD_HEADER && !ir->rem) if (ir->parser_state != CMD_HEADER && !ir->rem)
ir->parser_state = CMD_HEADER; ir->parser_state = CMD_HEADER;
} }
if (event) {
mce_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n"); mce_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n");
ir_raw_event_handle(ir->rc); ir_raw_event_handle(ir->rc);
}
} }
static void mceusb_dev_recv(struct urb *urb) static void mceusb_dev_recv(struct urb *urb)
......
...@@ -121,8 +121,9 @@ static void ttusbir_bulk_complete(struct urb *urb) ...@@ -121,8 +121,9 @@ static void ttusbir_bulk_complete(struct urb *urb)
*/ */
static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf) static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)
{ {
struct ir_raw_event rawir;
unsigned i, v, b; unsigned i, v, b;
DEFINE_IR_RAW_EVENT(rawir); bool event = false;
init_ir_raw_event(&rawir); init_ir_raw_event(&rawir);
...@@ -132,12 +133,14 @@ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf) ...@@ -132,12 +133,14 @@ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)
case 0xfe: case 0xfe:
rawir.pulse = false; rawir.pulse = false;
rawir.duration = NS_PER_BYTE; 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; break;
case 0: case 0:
rawir.pulse = true; rawir.pulse = true;
rawir.duration = NS_PER_BYTE; 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; break;
default: default:
/* one edge per byte */ /* one edge per byte */
...@@ -150,15 +153,19 @@ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf) ...@@ -150,15 +153,19 @@ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)
} }
rawir.duration = NS_PER_BIT * (8 - b); 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.pulse = !rawir.pulse;
rawir.duration = NS_PER_BIT * b; 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; break;
} }
} }
/* don't wakeup when there's nothing to do */
if (event)
ir_raw_event_handle(tt->rc); ir_raw_event_handle(tt->rc);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment