linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Levitsky <maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: lirc-list-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: mchehab-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 3/5] IR: ene_ir: few bugfixes
Date: Fri, 15 Oct 2010 18:06:37 +0200	[thread overview]
Message-ID: <1287158799-21486-4-git-send-email-maximlevitsky@gmail.com> (raw)
In-Reply-To: <1287158799-21486-1-git-send-email-maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

This is a result of last round of debug with
Sami R <maesesami-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>.

Thank you Sami very much!

The biggest bug I fixed is that,
I was clobbering the CIRCFG register after it is setup
That wasn't a good idea really

And some small refactoring, etc.

Signed-off-by: Maxim Levitsky <maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/media/IR/ene_ir.c |   43 ++++++++++++++++++++-----------------------
 1 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/drivers/media/IR/ene_ir.c b/drivers/media/IR/ene_ir.c
index dc32509..8639621 100644
--- a/drivers/media/IR/ene_ir.c
+++ b/drivers/media/IR/ene_ir.c
@@ -156,11 +156,12 @@ static int ene_hw_detect(struct ene_device *dev)
 
 	ene_notice("Firmware regs: %02x %02x", fw_reg1, fw_reg2);
 
-	dev->hw_use_gpio_0a = fw_reg2 & ENE_FW2_GP0A;
-	dev->hw_learning_and_tx_capable = fw_reg2 & ENE_FW2_LEARNING;
-	dev->hw_extra_buffer = fw_reg1 & ENE_FW1_HAS_EXTRA_BUF;
-	dev->hw_fan_input = dev->hw_learning_and_tx_capable &&
-	    (fw_reg2 & ENE_FW2_FAN_INPUT);
+	dev->hw_use_gpio_0a = !!(fw_reg2 & ENE_FW2_GP0A);
+	dev->hw_learning_and_tx_capable = !!(fw_reg2 & ENE_FW2_LEARNING);
+	dev->hw_extra_buffer = !!(fw_reg1 & ENE_FW1_HAS_EXTRA_BUF);
+
+	if (dev->hw_learning_and_tx_capable)
+		dev->hw_fan_input = !!(fw_reg2 & ENE_FW2_FAN_INPUT);
 
 	ene_notice("Hardware features:");
 
@@ -255,6 +256,8 @@ static void ene_rx_setup(struct ene_device *dev)
 					dev->carrier_detect_enabled;
 	int sample_period_adjust = 0;
 
+	/* This selects RLC input and clears CFG2 settings */
+	ene_write_reg(dev, ENE_CIRCFG2, 0x00);
 
 	/* set sample period*/
 	if (sample_period == ENE_DEFAULT_SAMPLE_PERIOD)
@@ -268,7 +271,9 @@ static void ene_rx_setup(struct ene_device *dev)
 	if (dev->hw_revision < ENE_HW_C)
 		goto select_timeout;
 
-	if (learning_mode && dev->hw_learning_and_tx_capable) {
+	if (learning_mode) {
+
+		WARN_ON(!dev->hw_learning_and_tx_capable);
 
 		/* Enable the opposite of the normal input
 		That means that if GPIO40 is normally used, use GPIO0A
@@ -282,6 +287,7 @@ static void ene_rx_setup(struct ene_device *dev)
 		ene_set_reg_mask(dev, ENE_CIRCFG, ENE_CIRCFG_CARR_DEMOD);
 
 		/* Enable carrier detection */
+		ene_write_reg(dev, ENE_CIRCAR_PULS, 0x63);
 		ene_set_clear_reg_mask(dev, ENE_CIRCFG2, ENE_CIRCFG2_CARR_DETECT,
 			dev->carrier_detect_enabled || debug);
 	} else {
@@ -343,19 +349,9 @@ static void ene_rx_enable(struct ene_device *dev)
 		ene_write_reg(dev, ENE_IRQ, reg_value);
 	}
 
-	if (dev->hw_revision >= ENE_HW_C)
-		ene_write_reg(dev, ENE_CIRCAR_PULS, 0x63);
-
-	/* Enable the inputs */
-	ene_write_reg(dev, ENE_CIRCFG2, 0x00);
-
-	if (dev->rx_fan_input_inuse) {
-		ene_enable_cir_engine(dev, false);
-		ene_enable_fan_input(dev, true);
-	} else {
-		ene_enable_cir_engine(dev, true);
-		ene_enable_fan_input(dev, false);
-	}
+	/* Enable inputs */
+	ene_enable_fan_input(dev, dev->rx_fan_input_inuse);
+	ene_enable_cir_engine(dev, !dev->rx_fan_input_inuse);
 
 	/* ack any pending irqs - just in case */
 	ene_irq_status(dev);
@@ -793,12 +789,10 @@ static void ene_setup_settings(struct ene_device *dev)
 	dev->tx_period = 32;
 	dev->tx_duty_cycle = 50; /*%*/
 	dev->transmitter_mask = 0x03;
-
-	dev->learning_enabled =
-		(learning_mode && dev->hw_learning_and_tx_capable);
+	dev->learning_enabled = learning_mode;
 
 	/* Set reasonable default timeout */
-	dev->props->timeout = MS_TO_NS(15000);
+	dev->props->timeout = MS_TO_NS(150000);
 }
 
 /* outside interface: called on first open*/
@@ -1015,6 +1009,9 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
 		ene_warn("Simulation of TX activated");
 	}
 
+	if (!dev->hw_learning_and_tx_capable)
+		learning_mode = false;
+
 	ir_props->driver_type = RC_DRIVER_IR_RAW;
 	ir_props->allowed_protos = IR_TYPE_ALL;
 	ir_props->priv = dev;
-- 
1.7.1


------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev

  parent reply	other threads:[~2010-10-15 16:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-15 16:06 [PATCH 0/8 V7] Many fixes for in-kernel decoding and for the ENE driver Maxim Levitsky
     [not found] ` <1287158799-21486-1-git-send-email-maximlevitsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-10-15 16:06   ` [PATCH 1/5] IR: extend and sort the MCE keymap Maxim Levitsky
2010-10-15 19:48     ` Jarod Wilson
2010-10-15 16:06   ` [PATCH 2/5] IR: extend ir_raw_event and do refactoring Maxim Levitsky
2010-10-16  3:29     ` Mauro Carvalho Chehab
2010-10-16  4:11       ` Maxim Levitsky
2010-10-15 16:06   ` Maxim Levitsky [this message]
2010-10-15 20:02     ` [PATCH 3/5] IR: ene_ir: few bugfixes Jarod Wilson
     [not found]       ` <20101015200212.GK9658-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-10-15 20:24         ` Maxim Levitsky
2010-10-15 21:00           ` Jarod Wilson
2010-10-15 16:06   ` [PATCH 4/5] IR: ene_ir: add support for carrier reports Maxim Levitsky
2010-10-15 20:16     ` Jarod Wilson
2010-10-16  3:31     ` Mauro Carvalho Chehab
2010-10-15 16:06   ` [PATCH 5/5] IR: ene_ir: don't upload all settings on each TX packet Maxim Levitsky
2010-10-16  3:23 ` [PATCH 0/8 V7] Many fixes for in-kernel decoding and for the ENE driver Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287158799-21486-4-git-send-email-maximlevitsky@gmail.com \
    --to=maximlevitsky-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lirc-list-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=mchehab-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).