aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2012-08-13 07:59:47 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-13 15:19:12 -0400
commitb83bfd1b0127b0963fcac39280280e365e7e04d8 (patch)
tree3a7d76ffb8844af1ce9ffb5299d6f2726699c3e5
parent0938069fa08970f1c898970c1331a029efe9a1ce (diff)
[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>
-rw-r--r--drivers/media/rc/fintek-cir.c11
-rw-r--r--drivers/media/rc/iguanair.c7
-rw-r--r--drivers/media/rc/ir-raw.c6
-rw-r--r--drivers/media/rc/mceusb.c10
-rw-r--r--drivers/media/rc/ttusbir.c19
5 files changed, 37 insertions, 16 deletions
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index ab30c64f8124..52fd7696b1ba 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -295,6 +295,7 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
295{ 295{
296 DEFINE_IR_RAW_EVENT(rawir); 296 DEFINE_IR_RAW_EVENT(rawir);
297 u8 sample; 297 u8 sample;
298 bool event = false;
298 int i; 299 int i;
299 300
300 for (i = 0; i < fintek->pkts; i++) { 301 for (i = 0; i < fintek->pkts; i++) {
@@ -332,7 +333,9 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
332 fit_dbg("Storing %s with duration %d", 333 fit_dbg("Storing %s with duration %d",
333 rawir.pulse ? "pulse" : "space", 334 rawir.pulse ? "pulse" : "space",
334 rawir.duration); 335 rawir.duration);
335 ir_raw_event_store_with_filter(fintek->rdev, &rawir); 336 if (ir_raw_event_store_with_filter(fintek->rdev,
337 &rawir))
338 event = true;
336 break; 339 break;
337 } 340 }
338 341
@@ -342,8 +345,10 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
342 345
343 fintek->pkts = 0; 346 fintek->pkts = 0;
344 347
345 fit_dbg("Calling ir_raw_event_handle"); 348 if (event) {
346 ir_raw_event_handle(fintek->rdev); 349 fit_dbg("Calling ir_raw_event_handle");
350 ir_raw_event_handle(fintek->rdev);
351 }
347} 352}
348 353
349/* copy data from hardware rx register into driver buffer */ 354/* copy data from hardware rx register into driver buffer */
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index 6a09c2e53753..66ba23738601 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -134,6 +134,7 @@ static void process_ir_data(struct iguanair *ir, unsigned len)
134 } else if (len >= 7) { 134 } else if (len >= 7) {
135 DEFINE_IR_RAW_EVENT(rawir); 135 DEFINE_IR_RAW_EVENT(rawir);
136 unsigned i; 136 unsigned i;
137 bool event = false;
137 138
138 init_ir_raw_event(&rawir); 139 init_ir_raw_event(&rawir);
139 140
@@ -147,10 +148,12 @@ static void process_ir_data(struct iguanair *ir, unsigned len)
147 RX_RESOLUTION; 148 RX_RESOLUTION;
148 } 149 }
149 150
150 ir_raw_event_store_with_filter(ir->rc, &rawir); 151 if (ir_raw_event_store_with_filter(ir->rc, &rawir))
152 event = true;
151 } 153 }
152 154
153 ir_raw_event_handle(ir->rc); 155 if (event)
156 ir_raw_event_handle(ir->rc);
154 } 157 }
155} 158}
156 159
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index a82025121345..97dc8d13b06b 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -157,7 +157,9 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);
157 * This routine (which may be called from an interrupt context) works 157 * This routine (which may be called from an interrupt context) works
158 * in similar manner to ir_raw_event_store_edge. 158 * in similar manner to ir_raw_event_store_edge.
159 * This routine is intended for devices with limited internal buffer 159 * This routine is intended for devices with limited internal buffer
160 * It automerges samples of same type, and handles timeouts 160 * It automerges samples of same type, and handles timeouts. Returns non-zero
161 * if the event was added, and zero if the event was ignored due to idle
162 * processing.
161 */ 163 */
162int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev) 164int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev)
163{ 165{
@@ -184,7 +186,7 @@ int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev)
184 dev->raw->this_ev.duration >= dev->timeout) 186 dev->raw->this_ev.duration >= dev->timeout)
185 ir_raw_event_set_idle(dev, true); 187 ir_raw_event_set_idle(dev, true);
186 188
187 return 0; 189 return 1;
188} 190}
189EXPORT_SYMBOL_GPL(ir_raw_event_store_with_filter); 191EXPORT_SYMBOL_GPL(ir_raw_event_store_with_filter);
190 192
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index f38d9a8c6880..d289fd42729f 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -974,6 +974,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index)
974static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) 974static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
975{ 975{
976 DEFINE_IR_RAW_EVENT(rawir); 976 DEFINE_IR_RAW_EVENT(rawir);
977 bool event = false;
977 int i = 0; 978 int i = 0;
978 979
979 /* skip meaningless 0xb1 0x60 header bytes on orig receiver */ 980 /* 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 rawir.pulse ? "pulse" : "space", 1005 rawir.pulse ? "pulse" : "space",
1005 rawir.duration); 1006 rawir.duration);
1006 1007
1007 ir_raw_event_store_with_filter(ir->rc, &rawir); 1008 if (ir_raw_event_store_with_filter(ir->rc, &rawir))
1009 event = true;
1008 break; 1010 break;
1009 case CMD_DATA: 1011 case CMD_DATA:
1010 ir->rem--; 1012 ir->rem--;
@@ -1032,8 +1034,10 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
1032 if (ir->parser_state != CMD_HEADER && !ir->rem) 1034 if (ir->parser_state != CMD_HEADER && !ir->rem)
1033 ir->parser_state = CMD_HEADER; 1035 ir->parser_state = CMD_HEADER;
1034 } 1036 }
1035 mce_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n"); 1037 if (event) {
1036 ir_raw_event_handle(ir->rc); 1038 mce_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n");
1039 ir_raw_event_handle(ir->rc);
1040 }
1037} 1041}
1038 1042
1039static void mceusb_dev_recv(struct urb *urb) 1043static void mceusb_dev_recv(struct urb *urb)
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index 71f03acabac8..1aee57fd2f32 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -121,8 +121,9 @@ static void ttusbir_bulk_complete(struct urb *urb)
121 */ 121 */
122static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf) 122static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)
123{ 123{
124 struct ir_raw_event rawir;
124 unsigned i, v, b; 125 unsigned i, v, b;
125 DEFINE_IR_RAW_EVENT(rawir); 126 bool event = false;
126 127
127 init_ir_raw_event(&rawir); 128 init_ir_raw_event(&rawir);
128 129
@@ -132,12 +133,14 @@ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)
132 case 0xfe: 133 case 0xfe:
133 rawir.pulse = false; 134 rawir.pulse = false;
134 rawir.duration = NS_PER_BYTE; 135 rawir.duration = NS_PER_BYTE;
135 ir_raw_event_store_with_filter(tt->rc, &rawir); 136 if (ir_raw_event_store_with_filter(tt->rc, &rawir))
137 event = true;
136 break; 138 break;
137 case 0: 139 case 0:
138 rawir.pulse = true; 140 rawir.pulse = true;
139 rawir.duration = NS_PER_BYTE; 141 rawir.duration = NS_PER_BYTE;
140 ir_raw_event_store_with_filter(tt->rc, &rawir); 142 if (ir_raw_event_store_with_filter(tt->rc, &rawir))
143 event = true;
141 break; 144 break;
142 default: 145 default:
143 /* one edge per byte */ 146 /* one edge per byte */
@@ -150,16 +153,20 @@ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)
150 } 153 }
151 154
152 rawir.duration = NS_PER_BIT * (8 - b); 155 rawir.duration = NS_PER_BIT * (8 - b);
153 ir_raw_event_store_with_filter(tt->rc, &rawir); 156 if (ir_raw_event_store_with_filter(tt->rc, &rawir))
157 event = true;
154 158
155 rawir.pulse = !rawir.pulse; 159 rawir.pulse = !rawir.pulse;
156 rawir.duration = NS_PER_BIT * b; 160 rawir.duration = NS_PER_BIT * b;
157 ir_raw_event_store_with_filter(tt->rc, &rawir); 161 if (ir_raw_event_store_with_filter(tt->rc, &rawir))
162 event = true;
158 break; 163 break;
159 } 164 }
160 } 165 }
161 166
162 ir_raw_event_handle(tt->rc); 167 /* don't wakeup when there's nothing to do */
168 if (event)
169 ir_raw_event_handle(tt->rc);
163} 170}
164 171
165static void ttusbir_urb_complete(struct urb *urb) 172static void ttusbir_urb_complete(struct urb *urb)