* [PATCH 1/3] [media] winbond-cir: only enable higher sample resolution if needed
@ 2013-01-06 17:19 Sean Young
2013-01-06 17:19 ` [PATCH 2/3] [media] iguanair: ensure transmission mask is initialized Sean Young
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sean Young @ 2013-01-06 17:19 UTC (permalink / raw)
To: Mauro Carvalho Chehab, David Härdeman; +Cc: linux-media
A sample resolution of 2us generates more than 300 interrupts per key
and this resolution is not needed unless carrier reports are enabled.
Revert to a resolution of 10us unless carrier reports are needed. This
generates up to a fifth of the interrupts.
Signed-off-by: Sean Young <sean@mess.org>
---
drivers/media/rc/winbond-cir.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 553d1cd..66f543c 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -154,6 +154,8 @@
#define WBCIR_CNTR_R 0x02
/* Invert TX */
#define WBCIR_IRTX_INV 0x04
+/* Receiver oversampling */
+#define WBCIR_RX_T_OV 0x40
/* Valid banks for the SP3 UART */
enum wbcir_bank {
@@ -394,7 +396,8 @@ wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device)
if (data->rxstate == WBCIR_RXSTATE_ERROR)
continue;
- duration = ((irdata & 0x7F) + 1) * 2;
+ duration = ((irdata & 0x7F) + 1) *
+ (data->carrier_report_enabled ? 2 : 10);
rawir.pulse = irdata & 0x80 ? false : true;
rawir.duration = US_TO_NS(duration);
@@ -550,6 +553,17 @@ wbcir_set_carrier_report(struct rc_dev *dev, int enable)
wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL,
WBCIR_CNTR_EN, WBCIR_CNTR_EN | WBCIR_CNTR_R);
+ /* Set a higher sampling resolution if carrier reports are enabled */
+ wbcir_select_bank(data, WBCIR_BANK_2);
+ data->dev->rx_resolution = US_TO_NS(enable ? 2 : 10);
+ outb(enable ? 0x03 : 0x0f, data->sbase + WBCIR_REG_SP3_BGDL);
+ outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
+
+ /* Enable oversampling if carrier reports are enabled */
+ wbcir_select_bank(data, WBCIR_BANK_7);
+ wbcir_set_bits(data->sbase + WBCIR_REG_SP3_RCCFG,
+ enable ? WBCIR_RX_T_OV : 0, WBCIR_RX_T_OV);
+
data->carrier_report_enabled = enable;
spin_unlock_irqrestore(&data->spinlock, flags);
@@ -931,8 +945,8 @@ wbcir_init_hw(struct wbcir_data *data)
/* prescaler 1.0, tx/rx fifo lvl 16 */
outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2);
- /* Set baud divisor to sample every 2 ns */
- outb(0x03, data->sbase + WBCIR_REG_SP3_BGDL);
+ /* Set baud divisor to sample every 10 us */
+ outb(0x0f, data->sbase + WBCIR_REG_SP3_BGDL);
outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
/* Set CEIR mode */
@@ -941,12 +955,9 @@ wbcir_init_hw(struct wbcir_data *data)
inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */
inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */
- /*
- * Disable RX demod, enable run-length enc/dec, set freq span and
- * enable over-sampling
- */
+ /* Disable RX demod, enable run-length enc/dec, set freq span */
wbcir_select_bank(data, WBCIR_BANK_7);
- outb(0xd0, data->sbase + WBCIR_REG_SP3_RCCFG);
+ outb(0x90, data->sbase + WBCIR_REG_SP3_RCCFG);
/* Disable timer */
wbcir_select_bank(data, WBCIR_BANK_4);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] [media] iguanair: ensure transmission mask is initialized
2013-01-06 17:19 [PATCH 1/3] [media] winbond-cir: only enable higher sample resolution if needed Sean Young
@ 2013-01-06 17:19 ` Sean Young
2013-01-06 17:19 ` [PATCH 3/3] [media] iguanair: intermittent initialization failure Sean Young
2013-01-08 11:32 ` [PATCH 1/3] [media] winbond-cir: only enable higher sample resolution if needed David Härdeman
2 siblings, 0 replies; 5+ messages in thread
From: Sean Young @ 2013-01-06 17:19 UTC (permalink / raw)
To: Mauro Carvalho Chehab, David Härdeman; +Cc: linux-media
Signed-off-by: Sean Young <sean@mess.org>
---
drivers/media/rc/iguanair.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index 5a9163d..a569c69 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -512,6 +512,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf,
rc->rx_resolution = RX_RESOLUTION;
iguanair_set_tx_carrier(rc, 38000);
+ iguanair_set_tx_mask(rc, 0);
ret = rc_register_device(rc);
if (ret < 0) {
--
1.7.11.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] [media] iguanair: intermittent initialization failure
2013-01-06 17:19 [PATCH 1/3] [media] winbond-cir: only enable higher sample resolution if needed Sean Young
2013-01-06 17:19 ` [PATCH 2/3] [media] iguanair: ensure transmission mask is initialized Sean Young
@ 2013-01-06 17:19 ` Sean Young
2013-01-12 11:42 ` Sean Young
2013-01-08 11:32 ` [PATCH 1/3] [media] winbond-cir: only enable higher sample resolution if needed David Härdeman
2 siblings, 1 reply; 5+ messages in thread
From: Sean Young @ 2013-01-06 17:19 UTC (permalink / raw)
To: Mauro Carvalho Chehab, David Härdeman; +Cc: linux-media
Sometimes the first version request is sent before the device has fully
initialized. This seems to happen on some hardware during boot when the
iguanair is plugged into a root hub.
Signed-off-by: Sean Young <sean@mess.org>
---
drivers/media/rc/iguanair.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index a569c69..bc3557b 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -224,6 +224,14 @@ static int iguanair_get_features(struct iguanair *ir)
ir->packet->header.cmd = CMD_GET_VERSION;
rc = iguanair_send(ir, sizeof(ir->packet->header));
+
+ /*
+ * We might have sent the command before the device had time to
+ * initialize. Retry if we got no response.
+ */
+ if (rc == -ETIMEDOUT)
+ rc = iguanair_send(ir, sizeof(ir->packet->header));
+
if (rc) {
dev_info(ir->dev, "failed to get version\n");
goto out;
@@ -255,19 +263,14 @@ static int iguanair_get_features(struct iguanair *ir)
ir->packet->header.cmd = CMD_GET_FEATURES;
rc = iguanair_send(ir, sizeof(ir->packet->header));
- if (rc) {
+ if (rc)
dev_info(ir->dev, "failed to get features\n");
- goto out;
- }
-
out:
return rc;
}
static int iguanair_receiver(struct iguanair *ir, bool enable)
{
- int rc;
-
ir->packet->header.start = 0;
ir->packet->header.direction = DIR_OUT;
ir->packet->header.cmd = enable ? CMD_RECEIVER_ON : CMD_RECEIVER_OFF;
@@ -275,9 +278,7 @@ static int iguanair_receiver(struct iguanair *ir, bool enable)
if (enable)
ir_raw_event_reset(ir->rc);
- rc = iguanair_send(ir, sizeof(ir->packet->header));
-
- return rc;
+ return iguanair_send(ir, sizeof(ir->packet->header));
}
/*
--
1.7.11.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] [media] iguanair: intermittent initialization failure
2013-01-06 17:19 ` [PATCH 3/3] [media] iguanair: intermittent initialization failure Sean Young
@ 2013-01-12 11:42 ` Sean Young
0 siblings, 0 replies; 5+ messages in thread
From: Sean Young @ 2013-01-12 11:42 UTC (permalink / raw)
To: Mauro Carvalho Chehab, David Härdeman; +Cc: linux-media
On Sun, Jan 06, 2013 at 05:19:45PM +0000, Sean Young wrote:
> Sometimes the first version request is sent before the device has fully
> initialized. This seems to happen on some hardware during boot when the
> iguanair is plugged into a root hub.
>
> Signed-off-by: Sean Young <sean@mess.org>
Mauro, please ignore this patch. I've found the cause in the firmware and
I've got a better way of solving this.
Thanks
Sean
> ---
> drivers/media/rc/iguanair.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
> index a569c69..bc3557b 100644
> --- a/drivers/media/rc/iguanair.c
> +++ b/drivers/media/rc/iguanair.c
> @@ -224,6 +224,14 @@ static int iguanair_get_features(struct iguanair *ir)
> ir->packet->header.cmd = CMD_GET_VERSION;
>
> rc = iguanair_send(ir, sizeof(ir->packet->header));
> +
> + /*
> + * We might have sent the command before the device had time to
> + * initialize. Retry if we got no response.
> + */
> + if (rc == -ETIMEDOUT)
> + rc = iguanair_send(ir, sizeof(ir->packet->header));
> +
> if (rc) {
> dev_info(ir->dev, "failed to get version\n");
> goto out;
> @@ -255,19 +263,14 @@ static int iguanair_get_features(struct iguanair *ir)
> ir->packet->header.cmd = CMD_GET_FEATURES;
>
> rc = iguanair_send(ir, sizeof(ir->packet->header));
> - if (rc) {
> + if (rc)
> dev_info(ir->dev, "failed to get features\n");
> - goto out;
> - }
> -
> out:
> return rc;
> }
>
> static int iguanair_receiver(struct iguanair *ir, bool enable)
> {
> - int rc;
> -
> ir->packet->header.start = 0;
> ir->packet->header.direction = DIR_OUT;
> ir->packet->header.cmd = enable ? CMD_RECEIVER_ON : CMD_RECEIVER_OFF;
> @@ -275,9 +278,7 @@ static int iguanair_receiver(struct iguanair *ir, bool enable)
> if (enable)
> ir_raw_event_reset(ir->rc);
>
> - rc = iguanair_send(ir, sizeof(ir->packet->header));
> -
> - return rc;
> + return iguanair_send(ir, sizeof(ir->packet->header));
> }
>
> /*
> --
> 1.7.11.7
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] [media] winbond-cir: only enable higher sample resolution if needed
2013-01-06 17:19 [PATCH 1/3] [media] winbond-cir: only enable higher sample resolution if needed Sean Young
2013-01-06 17:19 ` [PATCH 2/3] [media] iguanair: ensure transmission mask is initialized Sean Young
2013-01-06 17:19 ` [PATCH 3/3] [media] iguanair: intermittent initialization failure Sean Young
@ 2013-01-08 11:32 ` David Härdeman
2 siblings, 0 replies; 5+ messages in thread
From: David Härdeman @ 2013-01-08 11:32 UTC (permalink / raw)
To: Sean Young; +Cc: Mauro Carvalho Chehab, linux-media
On Sun, Jan 06, 2013 at 05:19:43PM +0000, Sean Young wrote:
>A sample resolution of 2us generates more than 300 interrupts per key
>and this resolution is not needed unless carrier reports are enabled.
>
>Revert to a resolution of 10us unless carrier reports are needed. This
>generates up to a fifth of the interrupts.
>
>Signed-off-by: Sean Young <sean@mess.org>
Thanks Sean!
Acked-by: David Härdeman <david@hardeman.nu>
>---
> drivers/media/rc/winbond-cir.c | 27 +++++++++++++++++++--------
> 1 file changed, 19 insertions(+), 8 deletions(-)
>
>diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
>index 553d1cd..66f543c 100644
>--- a/drivers/media/rc/winbond-cir.c
>+++ b/drivers/media/rc/winbond-cir.c
>@@ -154,6 +154,8 @@
> #define WBCIR_CNTR_R 0x02
> /* Invert TX */
> #define WBCIR_IRTX_INV 0x04
>+/* Receiver oversampling */
>+#define WBCIR_RX_T_OV 0x40
>
> /* Valid banks for the SP3 UART */
> enum wbcir_bank {
>@@ -394,7 +396,8 @@ wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device)
> if (data->rxstate == WBCIR_RXSTATE_ERROR)
> continue;
>
>- duration = ((irdata & 0x7F) + 1) * 2;
>+ duration = ((irdata & 0x7F) + 1) *
>+ (data->carrier_report_enabled ? 2 : 10);
> rawir.pulse = irdata & 0x80 ? false : true;
> rawir.duration = US_TO_NS(duration);
>
>@@ -550,6 +553,17 @@ wbcir_set_carrier_report(struct rc_dev *dev, int enable)
> wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL,
> WBCIR_CNTR_EN, WBCIR_CNTR_EN | WBCIR_CNTR_R);
>
>+ /* Set a higher sampling resolution if carrier reports are enabled */
>+ wbcir_select_bank(data, WBCIR_BANK_2);
>+ data->dev->rx_resolution = US_TO_NS(enable ? 2 : 10);
>+ outb(enable ? 0x03 : 0x0f, data->sbase + WBCIR_REG_SP3_BGDL);
>+ outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
>+
>+ /* Enable oversampling if carrier reports are enabled */
>+ wbcir_select_bank(data, WBCIR_BANK_7);
>+ wbcir_set_bits(data->sbase + WBCIR_REG_SP3_RCCFG,
>+ enable ? WBCIR_RX_T_OV : 0, WBCIR_RX_T_OV);
>+
> data->carrier_report_enabled = enable;
> spin_unlock_irqrestore(&data->spinlock, flags);
>
>@@ -931,8 +945,8 @@ wbcir_init_hw(struct wbcir_data *data)
> /* prescaler 1.0, tx/rx fifo lvl 16 */
> outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2);
>
>- /* Set baud divisor to sample every 2 ns */
>- outb(0x03, data->sbase + WBCIR_REG_SP3_BGDL);
>+ /* Set baud divisor to sample every 10 us */
>+ outb(0x0f, data->sbase + WBCIR_REG_SP3_BGDL);
> outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
>
> /* Set CEIR mode */
>@@ -941,12 +955,9 @@ wbcir_init_hw(struct wbcir_data *data)
> inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */
> inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */
>
>- /*
>- * Disable RX demod, enable run-length enc/dec, set freq span and
>- * enable over-sampling
>- */
>+ /* Disable RX demod, enable run-length enc/dec, set freq span */
> wbcir_select_bank(data, WBCIR_BANK_7);
>- outb(0xd0, data->sbase + WBCIR_REG_SP3_RCCFG);
>+ outb(0x90, data->sbase + WBCIR_REG_SP3_RCCFG);
>
> /* Disable timer */
> wbcir_select_bank(data, WBCIR_BANK_4);
>--
>1.7.11.7
>
--
David Härdeman
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-01-12 11:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-06 17:19 [PATCH 1/3] [media] winbond-cir: only enable higher sample resolution if needed Sean Young
2013-01-06 17:19 ` [PATCH 2/3] [media] iguanair: ensure transmission mask is initialized Sean Young
2013-01-06 17:19 ` [PATCH 3/3] [media] iguanair: intermittent initialization failure Sean Young
2013-01-12 11:42 ` Sean Young
2013-01-08 11:32 ` [PATCH 1/3] [media] winbond-cir: only enable higher sample resolution if needed David Härdeman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).