diff options
author | David Härdeman <david@hardeman.nu> | 2011-04-28 11:13:27 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-05-20 08:29:54 -0400 |
commit | 488ebc4808162245be1f1365ea6854b4af6a1146 (patch) | |
tree | 7a794123ca1e51f983a5d96fd7f3f9ac356c8def /drivers/media/rc/winbond-cir.c | |
parent | 08ffff9fa410916f1847aff831206465cefa924f (diff) |
[media] rc-core: use ir_raw_event_store_with_filter in winbond-cir
Using ir_raw_event_store_with_filter() saves about 20 lines of code.
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/rc/winbond-cir.c')
-rw-r--r-- | drivers/media/rc/winbond-cir.c | 63 |
1 files changed, 21 insertions, 42 deletions
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c index c42a8ed36c92..5d06b899e859 100644 --- a/drivers/media/rc/winbond-cir.c +++ b/drivers/media/rc/winbond-cir.c | |||
@@ -330,60 +330,38 @@ wbcir_to_rc6cells(u8 val) | |||
330 | *****************************************************************************/ | 330 | *****************************************************************************/ |
331 | 331 | ||
332 | static void | 332 | static void |
333 | wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device) | 333 | wbcir_idle_rx(struct rc_dev *dev, bool idle) |
334 | { | 334 | { |
335 | u8 irdata[8]; | 335 | struct wbcir_data *data = dev->priv; |
336 | bool disable = true; | ||
337 | unsigned int i; | ||
338 | 336 | ||
339 | if (data->rxstate == WBCIR_RXSTATE_INACTIVE) { | 337 | if (!idle && data->rxstate == WBCIR_RXSTATE_INACTIVE) { |
340 | data->rxstate = WBCIR_RXSTATE_ACTIVE; | 338 | data->rxstate = WBCIR_RXSTATE_ACTIVE; |
341 | led_trigger_event(data->rxtrigger, LED_FULL); | 339 | led_trigger_event(data->rxtrigger, LED_FULL); |
342 | } | 340 | } |
343 | 341 | ||
344 | /* Since RXHDLEV is set, at least 8 bytes are in the FIFO */ | 342 | if (idle && data->rxstate != WBCIR_RXSTATE_INACTIVE) |
345 | insb(data->sbase + WBCIR_REG_SP3_RXDATA, &irdata[0], 8); | 343 | /* Tell hardware to go idle by setting RXINACTIVE */ |
346 | 344 | outb(WBCIR_RX_DISABLE, data->sbase + WBCIR_REG_SP3_ASCR); | |
347 | for (i = 0; i < 8; i++) { | 345 | } |
348 | u8 pulse; | ||
349 | u32 duration; | ||
350 | 346 | ||
351 | if (irdata[i] != 0xFF && irdata[i] != 0x00) | 347 | static void |
352 | disable = false; | 348 | wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device) |
349 | { | ||
350 | u8 irdata; | ||
351 | DEFINE_IR_RAW_EVENT(rawir); | ||
353 | 352 | ||
353 | /* Since RXHDLEV is set, at least 8 bytes are in the FIFO */ | ||
354 | while (inb(data->sbase + WBCIR_REG_SP3_LSR) & WBCIR_RX_AVAIL) { | ||
355 | irdata = inb(data->sbase + WBCIR_REG_SP3_RXDATA); | ||
354 | if (data->rxstate == WBCIR_RXSTATE_ERROR) | 356 | if (data->rxstate == WBCIR_RXSTATE_ERROR) |
355 | continue; | 357 | continue; |
356 | 358 | rawir.pulse = irdata & 0x80 ? false : true; | |
357 | pulse = irdata[i] & 0x80 ? false : true; | 359 | rawir.duration = US_TO_NS((irdata & 0x7F) * 10); |
358 | duration = (irdata[i] & 0x7F) * 10000; /* ns */ | 360 | ir_raw_event_store_with_filter(data->dev, &rawir); |
359 | |||
360 | if (data->rxev.pulse != pulse) { | ||
361 | if (data->rxev.duration != 0) { | ||
362 | ir_raw_event_store(data->dev, &data->rxev); | ||
363 | data->rxev.duration = 0; | ||
364 | } | ||
365 | |||
366 | data->rxev.pulse = pulse; | ||
367 | } | ||
368 | |||
369 | data->rxev.duration += duration; | ||
370 | } | 361 | } |
371 | 362 | ||
372 | if (disable) { | 363 | /* Check if we should go idle */ |
373 | if (data->rxev.duration != 0 && | 364 | if (data->dev->idle) { |
374 | data->rxstate != WBCIR_RXSTATE_ERROR) { | ||
375 | ir_raw_event_store(data->dev, &data->rxev); | ||
376 | data->rxev.duration = 0; | ||
377 | } | ||
378 | |||
379 | /* Set RXINACTIVE */ | ||
380 | outb(WBCIR_RX_DISABLE, data->sbase + WBCIR_REG_SP3_ASCR); | ||
381 | |||
382 | /* Drain the FIFO */ | ||
383 | while (inb(data->sbase + WBCIR_REG_SP3_LSR) & WBCIR_RX_AVAIL) | ||
384 | inb(data->sbase + WBCIR_REG_SP3_RXDATA); | ||
385 | |||
386 | ir_raw_event_reset(data->dev); | ||
387 | led_trigger_event(data->rxtrigger, LED_OFF); | 365 | led_trigger_event(data->rxtrigger, LED_OFF); |
388 | data->rxstate = WBCIR_RXSTATE_INACTIVE; | 366 | data->rxstate = WBCIR_RXSTATE_INACTIVE; |
389 | } | 367 | } |
@@ -1088,6 +1066,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id) | |||
1088 | data->dev->input_id.product = WBCIR_ID_FAMILY; | 1066 | data->dev->input_id.product = WBCIR_ID_FAMILY; |
1089 | data->dev->input_id.version = WBCIR_ID_CHIP; | 1067 | data->dev->input_id.version = WBCIR_ID_CHIP; |
1090 | data->dev->map_name = RC_MAP_RC6_MCE; | 1068 | data->dev->map_name = RC_MAP_RC6_MCE; |
1069 | data->dev->s_idle = wbcir_idle_rx; | ||
1091 | data->dev->s_tx_mask = wbcir_txmask; | 1070 | data->dev->s_tx_mask = wbcir_txmask; |
1092 | data->dev->s_tx_carrier = wbcir_txcarrier; | 1071 | data->dev->s_tx_carrier = wbcir_txcarrier; |
1093 | data->dev->tx_ir = wbcir_tx; | 1072 | data->dev->tx_ir = wbcir_tx; |