Skip to contentSkip to conversation

(unknown)

PATCH Superseded Maxim Levitsky 5 participants 36 messages Jul 28, 2010 – Jul 30, 2010

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

Subject: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Hi,
This is second version of the patchset. Hopefully, I didn't forget to address all comments.

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Note that I send timeout report with zero value.
I don't think that this value is importaint.

#1 lore raw

PATCH v2 1/9 IR: Kconfig fixes

Move IR drives below separate menu.
This allows to disable them.
Also correct a typo.

---
 drivers/media/IR/Kconfig |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/media/IR/Kconfig +7 -3
index e557ae0..fc48a3f 100644
@@ -1,8 +1,10 @@
-config IR_CORE
-	tristate
+menuconfig IR_CORE
+	tristate "Infrared remote controller adapters"
 	depends on INPUT
 	default INPUT
 
+if IR_CORE
+
 config VIDEO_IR
 	tristate
 	depends on IR_CORE
@@ -16,7 +18,7 @@ config LIRC
 	   Enable this option to build the Linux Infrared Remote
 	   Control (LIRC) core device interface driver. The LIRC
 	   interface passes raw IR to and from userspace, where the
-	   LIRC daemon handles protocol decoding for IR reception ann
+	   LIRC daemon handles protocol decoding for IR reception and
 	   encoding for IR transmitting (aka "blasting").
 
 source "drivers/media/IR/keymaps/Kconfig"
@@ -102,3 +104,5 @@ config IR_MCEUSB
 
 	   To compile this driver as a module, choose M here: the
 	   module will be called mceusb.
+
+endif #IR_CORE
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v2 2/9 IR: minor fixes:

In reply to Maxim Levitsky

* lirc: Don't propagate reset event to userspace
* lirc: Remove strange logic from lirc that would make first sample always be pulse
* Make TO_US macro actualy print what it should.

---
 drivers/media/IR/ir-core-priv.h  |    4 +---
 drivers/media/IR/ir-lirc-codec.c |   14 ++++++++------
 drivers/media/IR/ir-raw-event.c  |    3 +++
 3 files changed, 12 insertions(+), 9 deletions(-)
drivers/media/IR/ir-core-priv.h +1 -3
index babd520..dc26e2b 100644
@@ -76,7 +76,6 @@ struct ir_raw_event_ctrl {
 	struct lirc_codec {
 		struct ir_input_dev *ir_dev;
 		struct lirc_driver *drv;
-		int lircdata;
 	} lirc;
 };
 
@@ -104,10 +103,9 @@ static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration)
 		ev->duration -= duration;
 }
 
-#define TO_US(duration)			(((duration) + 500) / 1000)
+#define TO_US(duration)			DIV_ROUND_CLOSEST((duration), 1000)
 #define TO_STR(is_pulse)		((is_pulse) ? "pulse" : "space")
 #define IS_RESET(ev)			(ev.duration == 0)
-
 /*
  * Routines from ir-sysfs.c - Meant to be called only internally inside
  * ir-core
drivers/media/IR/ir-lirc-codec.c +8 -6
index 3ba482d..8ca01fd 100644
@@ -32,6 +32,7 @@
 static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 {
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
+	int sample;
 
 	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_LIRC))
 		return 0;
@@ -39,18 +40,21 @@ static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 	if (!ir_dev->raw->lirc.drv || !ir_dev->raw->lirc.drv->rbuf)
 		return -EINVAL;
 
+	if (IS_RESET(ev))
+		return 0;
+
 	IR_dprintk(2, "LIRC data transfer started (%uus %s)\n",
 		   TO_US(ev.duration), TO_STR(ev.pulse));
 
-	ir_dev->raw->lirc.lircdata += ev.duration / 1000;
+
+	sample = ev.duration / 1000;
 	if (ev.pulse)
-		ir_dev->raw->lirc.lircdata |= PULSE_BIT;
+		sample |= PULSE_BIT;
 
 	lirc_buffer_write(ir_dev->raw->lirc.drv->rbuf,
-			  (unsigned char *) &ir_dev->raw->lirc.lircdata);
+			  (unsigned char *) &sample);
 	wake_up(&ir_dev->raw->lirc.drv->rbuf->wait_poll);
 
-	ir_dev->raw->lirc.lircdata = 0;
 
 	return 0;
 }
@@ -224,8 +228,6 @@ static int ir_lirc_register(struct input_dev *input_dev)
 
 	ir_dev->raw->lirc.drv = drv;
 	ir_dev->raw->lirc.ir_dev = ir_dev;
-	ir_dev->raw->lirc.lircdata = PULSE_MASK;
-
 	return 0;
 
 lirc_register_failed:
drivers/media/IR/ir-raw-event.c +3 -0
index 6f192ef..ab9c4da 100644
@@ -66,6 +66,9 @@ int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev)
 	if (!ir->raw)
 		return -EINVAL;
 
+	IR_dprintk(2, "sample: (05%dus %s)\n", TO_US(ev->duration),
+							TO_STR(ev->pulse));
+
 	if (kfifo_in(&ir->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev))
 		return -ENOMEM;
 
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH v2 3/9 IR: replace spinlock with mutex.

In reply to Maxim Levitsky

Some handlers (lirc for example) allocates memory on initialization, doing so in atomic context is cumbersome.
Fixes warning about sleeping function in atomic context.

---
 drivers/media/IR/ir-raw-event.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
drivers/media/IR/ir-raw-event.c +14 -14
index ab9c4da..c6a80b3 100644
@@ -13,7 +13,7 @@
  */
 
 #include <linux/workqueue.h>
-#include <linux/spinlock.h>
+#include <linux/mutex.h>
 #include <linux/sched.h>
 #include "ir-core-priv.h"
 
@@ -24,7 +24,7 @@
 static LIST_HEAD(ir_raw_client_list);
 
 /* Used to handle IR raw handler extensions */
-static DEFINE_SPINLOCK(ir_raw_handler_lock);
+static DEFINE_MUTEX(ir_raw_handler_lock);
 static LIST_HEAD(ir_raw_handler_list);
 static u64 available_protocols;
 
@@ -41,10 +41,10 @@ static void ir_raw_event_work(struct work_struct *work)
 		container_of(work, struct ir_raw_event_ctrl, rx_work);
 
 	while (kfifo_out(&raw->kfifo, &ev, sizeof(ev)) == sizeof(ev)) {
-		spin_lock(&ir_raw_handler_lock);
+		mutex_lock(&ir_raw_handler_lock);
 		list_for_each_entry(handler, &ir_raw_handler_list, list)
 			handler->decode(raw->input_dev, ev);
-		spin_unlock(&ir_raw_handler_lock);
+		mutex_unlock(&ir_raw_handler_lock);
 		raw->prev_ev = ev;
 	}
 }
@@ -150,9 +150,9 @@ u64
 ir_raw_get_allowed_protocols()
 {
 	u64 protocols;
-	spin_lock(&ir_raw_handler_lock);
+	mutex_lock(&ir_raw_handler_lock);
 	protocols = available_protocols;
-	spin_unlock(&ir_raw_handler_lock);
+	mutex_unlock(&ir_raw_handler_lock);
 	return protocols;
 }
 
@@ -180,12 +180,12 @@ int ir_raw_event_register(struct input_dev *input_dev)
 		return rc;
 	}
 
-	spin_lock(&ir_raw_handler_lock);
+	mutex_lock(&ir_raw_handler_lock);
 	list_add_tail(&ir->raw->list, &ir_raw_client_list);
 	list_for_each_entry(handler, &ir_raw_handler_list, list)
 		if (handler->raw_register)
 			handler->raw_register(ir->raw->input_dev);
-	spin_unlock(&ir_raw_handler_lock);
+	mutex_unlock(&ir_raw_handler_lock);
 
 	return 0;
 }
@@ -200,12 +200,12 @@ void ir_raw_event_unregister(struct input_dev *input_dev)
 
 	cancel_work_sync(&ir->raw->rx_work);
 
-	spin_lock(&ir_raw_handler_lock);
+	mutex_lock(&ir_raw_handler_lock);
 	list_del(&ir->raw->list);
 	list_for_each_entry(handler, &ir_raw_handler_list, list)
 		if (handler->raw_unregister)
 			handler->raw_unregister(ir->raw->input_dev);
-	spin_unlock(&ir_raw_handler_lock);
+	mutex_unlock(&ir_raw_handler_lock);
 
 	kfifo_free(&ir->raw->kfifo);
 	kfree(ir->raw);
@@ -220,13 +220,13 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler)
 {
 	struct ir_raw_event_ctrl *raw;
 
-	spin_lock(&ir_raw_handler_lock);
+	mutex_lock(&ir_raw_handler_lock);
 	list_add_tail(&ir_raw_handler->list, &ir_raw_handler_list);
 	if (ir_raw_handler->raw_register)
 		list_for_each_entry(raw, &ir_raw_client_list, list)
 			ir_raw_handler->raw_register(raw->input_dev);
 	available_protocols |= ir_raw_handler->protocols;
-	spin_unlock(&ir_raw_handler_lock);
+	mutex_unlock(&ir_raw_handler_lock);
 
 	return 0;
 }
@@ -236,13 +236,13 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)
 {
 	struct ir_raw_event_ctrl *raw;
 
-	spin_lock(&ir_raw_handler_lock);
+	mutex_lock(&ir_raw_handler_lock);
 	list_del(&ir_raw_handler->list);
 	if (ir_raw_handler->raw_unregister)
 		list_for_each_entry(raw, &ir_raw_client_list, list)
 			ir_raw_handler->raw_unregister(raw->input_dev);
 	available_protocols &= ~ir_raw_handler->protocols;
-	spin_unlock(&ir_raw_handler_lock);
+	mutex_unlock(&ir_raw_handler_lock);
 }
 EXPORT_SYMBOL(ir_raw_handler_unregister);
 
Signature · 1 line
1.7.0.4
#4 lore raw

PATCH v2 4/9 IR: add helper function for hardware with small o/b buffer.

In reply to Maxim Levitsky

Some ir input devices have small buffer, and interrupt the host each time it is full (or half full)

Add a helper that automaticly handles timeouts, and also automaticly merges samples of same time (space-space) Such samples might be placed by hardware because size of sample in the buffer is small (a byte for example).

---
 drivers/media/IR/ir-core-priv.h |    1 +
 drivers/media/IR/ir-keytable.c  |    2 +-
 drivers/media/IR/ir-raw-event.c |   86 +++++++++++++++++++++++++++++++++++++++
 include/media/ir-core.h         |   24 +++++++++-
 4 files changed, 109 insertions(+), 4 deletions(-)
drivers/media/IR/ir-core-priv.h +1 -0
index dc26e2b..d6ec4fe 100644
@@ -36,6 +36,7 @@ struct ir_raw_event_ctrl {
 	struct kfifo			kfifo;		/* fifo for the pulse/space durations */
 	ktime_t				last_event;	/* when last event occurred */
 	enum raw_event_type		last_type;	/* last event type */
+	struct ir_raw_event		current_sample;	/* sample that is not yet pushed to fifo */
 	struct input_dev		*input_dev;	/* pointer to the parent input_dev */
 	u64				enabled_protocols; /* enabled raw protocol decoders */
 
drivers/media/IR/ir-keytable.c +1 -1
index 94a8577..34b9c07 100644
@@ -428,7 +428,7 @@ static void ir_close(struct input_dev *input_dev)
  */
 int __ir_input_register(struct input_dev *input_dev,
 		      const struct ir_scancode_table *rc_tab,
-		      const struct ir_dev_props *props,
+		      struct ir_dev_props *props,
 		      const char *driver_name)
 {
 	struct ir_input_dev *ir_dev;
drivers/media/IR/ir-raw-event.c +86 -0

92 lines not on this page · raw message

include/media/ir-core.h +21 -3
index 513e60d..e895054 100644
@@ -41,6 +41,9 @@ enum rc_driver_type {
  *	anything with it. Yet, as the same keycode table can be used with other
  *	devices, a mask is provided to allow its usage. Drivers should generally
  *	leave this field in blank
+ * @timeout: optional time after which device stops sending data
+ * @min_timeout: minimum timeout supported by device
+ * @max_timeout: maximum timeout supported by device
  * @priv: driver-specific data, to be used on the callbacks
  * @change_protocol: allow changing the protocol used on hardware decoders
  * @open: callback to allow drivers to enable polling/irq when IR input device
@@ -50,11 +53,19 @@ enum rc_driver_type {
  * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs)
  * @s_tx_carrier: set transmit carrier frequency
  * @tx_ir: transmit IR
+ * @s_idle: optional: enable/disable hardware idle mode, upon which,
+	device doesn't interrupt host untill it sees IR data
  */
 struct ir_dev_props {
 	enum rc_driver_type	driver_type;
 	unsigned long		allowed_protos;
 	u32			scanmask;
+
+	u64			timeout;
+	u64			min_timeout;
+	u64			max_timeout;
+
+
 	void			*priv;
 	int			(*change_protocol)(void *priv, u64 ir_type);
 	int			(*open)(void *priv);
@@ -62,6 +73,7 @@ struct ir_dev_props {
 	int			(*s_tx_mask)(void *priv, u32 mask);
 	int			(*s_tx_carrier)(void *priv, u32 carrier);
 	int			(*tx_ir)(void *priv, int *txbuf, u32 n);
+	void			(*s_idle) (void *priv, int enable);
 };
 
 struct ir_input_dev {
@@ -69,9 +81,10 @@ struct ir_input_dev {
 	char				*driver_name;	/* Name of the driver module */
 	struct ir_scancode_table	rc_tab;		/* scan/key table */
 	unsigned long			devno;		/* device number */
-	const struct ir_dev_props	*props;		/* Device properties */
+	struct ir_dev_props		*props;		/* Device properties */
 	struct ir_raw_event_ctrl	*raw;		/* for raw pulse/space events */
 	struct input_dev		*input_dev;	/* the input device associated with this device */
+	bool				idle;
 
 	/* key info - needed by IR keycode handlers */
 	spinlock_t			keylock;	/* protects the below members */
@@ -95,12 +108,12 @@ enum raw_event_type {
 /* From ir-keytable.c */
 int __ir_input_register(struct input_dev *dev,
 		      const struct ir_scancode_table *ir_codes,
-		      const struct ir_dev_props *props,
+		      struct ir_dev_props *props,
 		      const char *driver_name);
 
 static inline int ir_input_register(struct input_dev *dev,
 		      const char *map_name,
-		      const struct ir_dev_props *props,
+		      struct ir_dev_props *props,
 		      const char *driver_name) {
 	struct ir_scancode_table *ir_codes;
 	struct ir_input_dev *ir_dev;
@@ -144,6 +157,11 @@ struct ir_raw_event {
 void ir_raw_event_handle(struct input_dev *input_dev);
 int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev);
 int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type type);
+int ir_raw_event_store_with_filter(struct input_dev *input_dev,
+						struct ir_raw_event *ev);
+
+void ir_raw_event_set_idle(struct input_dev *input_dev, int idle);
+
 static inline void ir_raw_event_reset(struct input_dev *input_dev)
 {
 	struct ir_raw_event ev = { .pulse = false, .duration = 0 };
Signature · 1 line
1.7.0.4
#5 lore raw

PATCH v2 5/9 IR: extend interfaces to support more device settings

In reply to Maxim Levitsky

Also reuse LIRC_SET_MEASURE_CARRIER_MODE as LIRC_SET_LEARN_MODE (LIRC_SET_LEARN_MODE will start carrier reports if possible, and tune receiver to wide band mode)

This IOCTL isn't yet used by lirc, so this won't break userspace.

Note that drivers currently can't report carrier, because raw event doesn't have space to indicate that.

---
 drivers/media/IR/ir-core-priv.h  |    2 +
 drivers/media/IR/ir-lirc-codec.c |  119 +++++++++++++++++++++++++++++++-------
 drivers/media/IR/ir-raw-event.c  |   13 ++---
 include/media/ir-core.h          |   11 ++++
 include/media/lirc.h             |    4 +-
 5 files changed, 117 insertions(+), 32 deletions(-)
drivers/media/IR/ir-core-priv.h +2 -0
index d6ec4fe..9c594af 100644
@@ -77,6 +77,8 @@ struct ir_raw_event_ctrl {
 	struct lirc_codec {
 		struct ir_input_dev *ir_dev;
 		struct lirc_driver *drv;
+		int timeout_report;
+		int carrier_low;
 	} lirc;
 };
 
drivers/media/IR/ir-lirc-codec.c +97 -22

185 lines not on this page · raw message

drivers/media/IR/ir-raw-event.c +5 -8
index bdf2ed8..2a5b824 100644
@@ -187,6 +187,9 @@ void ir_raw_event_set_idle(struct input_dev *input_dev, int idle)
 
 	if (idle) {
 		IR_dprintk(2, "enter idle mode\n");
+		ir_raw_event_store(input_dev, &raw->current_sample);
+		ir_raw_event_reset(input_dev);
+		raw->current_sample.duration = 0;
 		raw->last_event = ktime_get();
 	} else {
 		IR_dprintk(2, "exit idle mode\n");
@@ -194,17 +197,11 @@ void ir_raw_event_set_idle(struct input_dev *input_dev, int idle)
 		now = ktime_get();
 		delta = ktime_to_ns(ktime_sub(now, ir->raw->last_event));
 
-		WARN_ON(raw->current_sample.pulse);
-
-		raw->current_sample.duration =
-			min(raw->current_sample.duration + delta,
+		raw->current_sample.duration = min(delta,
 						(u64)IR_MAX_DURATION);
+		raw->current_sample.pulse = false;
 
 		ir_raw_event_store(input_dev, &raw->current_sample);
-
-		if (raw->current_sample.duration == IR_MAX_DURATION)
-			ir_raw_event_reset(input_dev);
-
 		raw->current_sample.duration = 0;
 	}
 out:
include/media/ir-core.h +11 -0
index e895054..7299e7a 100644
@@ -44,6 +44,8 @@ enum rc_driver_type {
  * @timeout: optional time after which device stops sending data
  * @min_timeout: minimum timeout supported by device
  * @max_timeout: maximum timeout supported by device
+ * @rx_resolution : resolution (in ns) of input sampler
+ * @tx_resolution: resolution (in ns) of output sampler
  * @priv: driver-specific data, to be used on the callbacks
  * @change_protocol: allow changing the protocol used on hardware decoders
  * @open: callback to allow drivers to enable polling/irq when IR input device
@@ -52,9 +54,12 @@ enum rc_driver_type {
  *	is opened.
  * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs)
  * @s_tx_carrier: set transmit carrier frequency
+ * @s_tx_duty_cycle: set transmit duty cycle (0% - 100%)
+ * @s_rx_carrier: inform driver about carrier it is expected to handle
  * @tx_ir: transmit IR
  * @s_idle: optional: enable/disable hardware idle mode, upon which,
 	device doesn't interrupt host untill it sees IR data
+ * @s_learning_mode: enable learning mode
  */
 struct ir_dev_props {
 	enum rc_driver_type	driver_type;
@@ -65,6 +70,8 @@ struct ir_dev_props {
 	u64			min_timeout;
 	u64			max_timeout;
 
+	u32			rx_resolution;
+	u32			tx_resolution;
 
 	void			*priv;
 	int			(*change_protocol)(void *priv, u64 ir_type);
@@ -72,8 +79,12 @@ struct ir_dev_props {
 	void			(*close)(void *priv);
 	int			(*s_tx_mask)(void *priv, u32 mask);
 	int			(*s_tx_carrier)(void *priv, u32 carrier);
+	int			(*s_tx_duty_cycle) (void *priv, u32 duty_cycle);
+	int			(*s_rx_carrier_range) (void *priv, u32 min, u32 max);
 	int			(*tx_ir)(void *priv, int *txbuf, u32 n);
 	void			(*s_idle) (void *priv, int enable);
+	int			(*s_learning_mode) (void *priv, int enable);
+
 };
 
 struct ir_input_dev {
include/media/lirc.h +2 -2
index 42c467c..caf172b 100644
@@ -76,7 +76,7 @@
 #define LIRC_CAN_SET_REC_TIMEOUT          0x10000000
 #define LIRC_CAN_SET_REC_FILTER           0x08000000
 
-#define LIRC_CAN_MEASURE_CARRIER          0x02000000
+#define LIRC_CAN_LEARN_MODE               0x02000000
 
 #define LIRC_CAN_SEND(x) ((x)&LIRC_CAN_SEND_MASK)
 #define LIRC_CAN_REC(x) ((x)&LIRC_CAN_REC_MASK)
@@ -145,7 +145,7 @@
  * if enabled from the next key press on the driver will send
  * LIRC_MODE2_FREQUENCY packets
  */
-#define LIRC_SET_MEASURE_CARRIER_MODE  _IOW('i', 0x0000001d, __u32)
+#define LIRC_SET_LEARN_MODE		_IOW('i', 0x0000001d, __u32)
 
 /*
  * to set a range use
Signature · 1 line
1.7.0.4
#6 lore raw

Re: [PATCH 5/9] IR: extend interfaces to support more device settings

Hi!

Quoted 3 lines · Maxim Levitsky "[email protected]" wrote:

Also reuse LIRC_SET_MEASURE_CARRIER_MODE as LIRC_SET_LEARN_MODE (LIRC_SET_LEARN_MODE will start carrier reports if possible, and tune receiver to wide band mode)

I don't like the rename of the ioctl. The ioctl should enable carrier reports. Anything else is hardware specific. Learn mode gives a somewhat wrong association to me. irrecord always has been using "learn mode" without ever using this ioctl.

Christoph

#7 lore raw

Re: [PATCH 5/9] IR: extend interfaces to support more device settings

Quoted 4 lines · Christoph Bartelmus

Hi!

Maxim Levitsky "[email protected]" wrote:

Quoted 8 lines
Quoted 3 lines

Also reuse LIRC_SET_MEASURE_CARRIER_MODE as LIRC_SET_LEARN_MODE (LIRC_SET_LEARN_MODE will start carrier reports if possible, and tune receiver to wide band mode)

I don't like the rename of the ioctl. The ioctl should enable carrier reports. Anything else is hardware specific. Learn mode gives a somewhat wrong association to me. irrecord always has been using "learn mode" without ever using this ioctl.

Why?

Carrier measure (if supported by hardware I think should always be enabled, because it can help in-kernel decoders).
(Which raises seperate question on how to do so. I guess I will need to make ir_raw_event 64 bit after all...)

Another thing is reporting these results to lirc.
By default lirc shouldn't get carrier reports, but as soon as irrecord starts, it can place device in special mode that allows it to capture input better, and optionally do carrier reports.

Do you think carrier reports are needed by lircd?

Best regards,
Maxim Levitsky

#8 lore raw

Re: [PATCH 5/9] IR: extend interfaces to support more device settings

Hi Maxim,

Quoted 9 lines · Maxim Levitsky
Quoted 8 lines · Christoph Bartelmus

Hi!

Quoted 3 lines · Maxim Levitsky "[email protected]" wrote:

Also reuse LIRC_SET_MEASURE_CARRIER_MODE as LIRC_SET_LEARN_MODE (LIRC_SET_LEARN_MODE will start carrier reports if possible, and tune receiver to wide band mode)

Quoted 6 lines
Quoted 4 lines

I don't like the rename of the ioctl. The ioctl should enable carrier reports. Anything else is hardware specific. Learn mode gives a somewhat wrong association to me. irrecord always has been using "learn mode" without ever using this ioctl.

Why?

If an ioctl enables/disables measuring of the carrier, then call it LIRC_SET_MEASURE_CARRIER_MODE and not LIRC_SET_LEARN_MODE.

Whether we need a LIRC_ENABLE_WIDE_BAND_RECEIVER ioctl is another question.

Quoted 2 lines

Carrier measure (if supported by hardware I think should always be enabled, because it can help in-kernel decoders).

That does not work in the real-world scenario. All receivers with a high range demodulate the signal and you won't get the carrier.

[...]

Quoted 4 lines

Another thing is reporting these results to lirc.
By default lirc shouldn't get carrier reports, but as soon as irrecord starts, it can place device in special mode that allows it to capture input better, and optionally do carrier reports.

And that's what LIRC_SET_MEASURE_CARRIER_MODE is made for.

Quoted 1 line

Do you think carrier reports are needed by lircd?

No.

Christoph

#9 lore raw

PATCH v2 6/9 IR: Allow not to compile keymaps in.

In reply to Maxim Levitsky

Currently, ir device registration fails if keymap requested by driver is not found. Fix that by always compiling in the empty keymap, and using it as a failback.

---
 drivers/media/IR/ir-core-priv.h     |    3 +-
 drivers/media/IR/ir-sysfs.c         |    2 +
 drivers/media/IR/keymaps/Makefile   |    1 -
 drivers/media/IR/keymaps/rc-empty.c |   44 -----------------------------------
 drivers/media/IR/rc-map.c           |   23 ++++++++++++++++++
 include/media/ir-core.h             |    8 ++++-
 6 files changed, 33 insertions(+), 48 deletions(-)
 delete mode 100644 drivers/media/IR/keymaps/rc-empty.c
drivers/media/IR/ir-core-priv.h +2 -1
index 9c594af..78106a0 100644
@@ -127,7 +127,8 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);
 void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler);
 void ir_raw_init(void);
 
-
+int ir_rcmap_init(void);
+void ir_rcmap_cleanup(void);
 /*
  * Decoder initialization code
  *
drivers/media/IR/ir-sysfs.c +2 -0
index a841e51..936dff8 100644
@@ -341,6 +341,7 @@ static int __init ir_core_init(void)
 
 	/* Initialize/load the decoders/keymap code that will be used */
 	ir_raw_init();
+	ir_rcmap_init();
 
 	return 0;
 }
@@ -348,6 +349,7 @@ static int __init ir_core_init(void)
 static void __exit ir_core_exit(void)
 {
 	class_unregister(&ir_input_class);
+	ir_rcmap_cleanup();
 }
 
 module_init(ir_core_init);
drivers/media/IR/keymaps/Makefile +0 -1
index 86d3d1f..24992cd 100644
@@ -17,7 +17,6 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
 			rc-dm1105-nec.o \
 			rc-dntv-live-dvb-t.o \
 			rc-dntv-live-dvbt-pro.o \
-			rc-empty.o \
 			rc-em-terratec.o \
 			rc-encore-enltv2.o \
 			rc-encore-enltv.o \
drivers/media/IR/keymaps/rc-empty.c deleted +0 -44

44 lines not on this page · raw message

drivers/media/IR/rc-map.c +23 -0
index 46a8f15..689143f 100644
@@ -82,3 +82,26 @@ void ir_unregister_map(struct rc_keymap *map)
 }
 EXPORT_SYMBOL_GPL(ir_unregister_map);
 
+
+static struct ir_scancode empty[] = {
+	{ 0x2a, KEY_COFFEE },
+};
+
+static struct rc_keymap empty_map = {
+	.map = {
+		.scan    = empty,
+		.size    = ARRAY_SIZE(empty),
+		.ir_type = IR_TYPE_UNKNOWN,	/* Legacy IR type */
+		.name    = RC_MAP_EMPTY,
+	}
+};
+
+int ir_rcmap_init(void)
+{
+	return ir_register_map(&empty_map);
+}
+
+void ir_rcmap_cleanup(void)
+{
+	ir_unregister_map(&empty_map);
+}
include/media/ir-core.h +6 -2
index 7299e7a..cf17be3 100644
@@ -134,8 +134,12 @@ static inline int ir_input_register(struct input_dev *dev,
 		return -EINVAL;
 
 	ir_codes = get_rc_map(map_name);
-	if (!ir_codes)
-		return -EINVAL;
+	if (!ir_codes) {
+		ir_codes = get_rc_map(RC_MAP_EMPTY);
+
+		if (!ir_codes)
+			return -EINVAL;
+	}
 
 	rc = __ir_input_register(dev, ir_codes, props, driver_name);
 	if (rc < 0)
Signature · 1 line
1.7.0.4
#10 lore raw

PATCH v2 7/9 IR: report unknown scancodes the in-kernel decoders found.

In reply to Maxim Levitsky

This way it is possible to use evtest to create keymap for unknown remote.

---
 drivers/media/IR/ir-keytable.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/media/IR/ir-keytable.c +7 -0
index 34b9c07..4498c64 100644
@@ -339,6 +339,8 @@ void ir_repeat(struct input_dev *dev)
 
 	spin_lock_irqsave(&ir->keylock, flags);
 
+	input_event(dev, EV_MSC, MSC_SCAN, ir->last_scancode);
+
 	if (!ir->keypressed)
 		goto out;
 
@@ -383,9 +385,12 @@ void ir_keydown(struct input_dev *dev, int scancode, u8 toggle)
 	ir->last_toggle = toggle;
 	ir->last_keycode = keycode;
 
+	input_event(dev, EV_MSC, MSC_SCAN, scancode);
+
 	if (keycode == KEY_RESERVED)
 		goto out;
 
+
 	/* Register a keypress */
 	ir->keypressed = true;
 	IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n",
@@ -480,6 +485,8 @@ int __ir_input_register(struct input_dev *input_dev,
 
 	set_bit(EV_KEY, input_dev->evbit);
 	set_bit(EV_REP, input_dev->evbit);
+	set_bit(EV_MSC, input_dev->evbit);
+	set_bit(MSC_SCAN, input_dev->mscbit);
 
 	if (ir_setkeytable(input_dev, &ir_dev->rc_tab, rc_tab)) {
 		rc = -ENOMEM;
Signature · 1 line
1.7.0.4
#11 lore raw

PATCH v2 8/9 STAGING: remove lirc_ene0100 driver.

In reply to Maxim Levitsky

Add latest unported version of this driver to media/IR. Next patch will port it to ir core.

---
 drivers/media/IR/ene_ir.c           | 1176 +++++++++++++++++++++++++++++++++++
 drivers/media/IR/ene_ir.h           |  240 +++++++
 drivers/staging/lirc/Kconfig        |    8 -
 drivers/staging/lirc/Makefile       |    1 -
 drivers/staging/lirc/lirc_ene0100.c |  646 -------------------
 drivers/staging/lirc/lirc_ene0100.h |  169 -----
 6 files changed, 1416 insertions(+), 824 deletions(-)
 create mode 100644 drivers/media/IR/ene_ir.c
 create mode 100644 drivers/media/IR/ene_ir.h
 delete mode 100644 drivers/staging/lirc/lirc_ene0100.c
 delete mode 100644 drivers/staging/lirc/lirc_ene0100.h
drivers/media/IR/ene_ir.c new file +1176 -0
new file mode 100644
index 0000000..9d11caf
@@ -0,0 +1,1176 @@
+/*
+ * driver for ENE KB3926 B/C/D CIR (also known as ENE0100/ENE0200/ENE0201)
+ *
+ * Copyright (C) 2010 Maxim Levitsky <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pnp.h>
+#include <linux/io.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
+#include <linux/uaccess.h>
+#include "lirc_ene0100.h"
+
+
+static int sample_period = -1;
+static int enable_idle = 1;
+static int enable_duty_carrier;
+static int input = 1;
+static int debug;
+static int txsim;
+
+static void ene_rx_set_idle(struct ene_device *dev, int idle);
+static int ene_irq_status(struct ene_device *dev);
+static void ene_send_sample(struct ene_device *dev, unsigned long sample);
+
+/* read a hardware register */
+static u8 ene_hw_read_reg(struct ene_device *dev, u16 reg)
+{
+	u8 retval;
+	outb(reg >> 8, dev->hw_io + ENE_ADDR_HI);
+	outb(reg & 0xFF, dev->hw_io + ENE_ADDR_LO);
+	retval = inb(dev->hw_io + ENE_IO);
+
+	ene_dbg_verbose("reg %04x == %02x", reg, retval);
+	return retval;
+}
+
+/* write a hardware register */
+static void ene_hw_write_reg(struct ene_device *dev, u16 reg, u8 value)
+{
+	outb(reg >> 8, dev->hw_io + ENE_ADDR_HI);
+	outb(reg & 0xFF, dev->hw_io + ENE_ADDR_LO);
+	outb(value, dev->hw_io + ENE_IO);
+
+	ene_dbg_verbose("reg %04x <- %02x", reg, value);
+}
+
+/* change specific bits in hardware register */
+static void ene_hw_write_reg_mask(struct ene_device *dev,
+				  u16 reg, u8 value, u8 mask)
+{
+	u8 regvalue;
+
+	outb(reg >> 8, dev->hw_io + ENE_ADDR_HI);
+	outb(reg & 0xFF, dev->hw_io + ENE_ADDR_LO);
+
+	regvalue = inb(dev->hw_io + ENE_IO) & ~mask;
+	regvalue |= (value & mask);
+	outb(regvalue, dev->hw_io + ENE_IO);
+
+	ene_dbg_verbose("reg %04x <- %02x (mask=%02x)", reg, value, mask);
+}
+
+/* detect hardware features */
+static int ene_hw_detect(struct ene_device *dev)
+{
+	u8 chip_major, chip_minor;
+	u8 hw_revision, old_ver;
+	u8 tmp;
+	u8 fw_capabilities;
+
+	tmp = ene_hw_read_reg(dev, ENE_HW_UNK);
+	ene_hw_write_reg(dev, ENE_HW_UNK, tmp & ~ENE_HW_UNK_CLR);
+
+	chip_major = ene_hw_read_reg(dev, ENE_HW_VER_MAJOR);
+	chip_minor = ene_hw_read_reg(dev, ENE_HW_VER_MINOR);
+
+	ene_hw_write_reg(dev, ENE_HW_UNK, tmp);
+	hw_revision = ene_hw_read_reg(dev, ENE_HW_VERSION);
+	old_ver = ene_hw_read_reg(dev, ENE_HW_VER_OLD);
+
+	if (hw_revision == 0xFF) {
+
+		ene_printk(KERN_WARNING, "device seems to be disabled\n");
+		ene_printk(KERN_WARNING,
+			"send a mail to [email protected]\n");
+		ene_printk(KERN_WARNING, "please attach output of acpidump\n");
+		return -ENODEV;
+	}
+
+	if (chip_major == 0x33) {
+		ene_printk(KERN_WARNING, "chips 0x33xx aren't supported\n");
+		return -ENODEV;
+	}
+
+	if (chip_major == 0x39 && chip_minor == 0x26 && hw_revision == 0xC0) {
+		dev->hw_revision = ENE_HW_C;
+	} else if (old_ver == 0x24 && hw_revision == 0xC0) {
+		dev->hw_revision = ENE_HW_B;
+		ene_printk(KERN_NOTICE, "KB3926B detected\n");
+	} else {
+		dev->hw_revision = ENE_HW_D;
+		ene_printk(KERN_WARNING,
+			"unknown ENE chip detected, assuming KB3926D\n");
+		ene_printk(KERN_WARNING,
+			"driver support might be not complete");
+
+	}
+
+	ene_printk(KERN_DEBUG,
+		"chip is 0x%02x%02x - kbver = 0x%02x, rev = 0x%02x\n",
+			chip_major, chip_minor, old_ver, hw_revision);
+
+	/* detect features hardware supports */
+	if (dev->hw_revision < ENE_HW_C)
+		return 0;
+
+	fw_capabilities = ene_hw_read_reg(dev, ENE_FW2);
+	ene_dbg("Firmware capabilities: %02x", fw_capabilities);
+
+	dev->hw_gpio40_learning = fw_capabilities & ENE_FW2_GP40_AS_LEARN;
+	dev->hw_learning_and_tx_capable = fw_capabilities & ENE_FW2_LEARNING;
+
+	dev->hw_fan_as_normal_input = dev->hw_learning_and_tx_capable &&
+	    (fw_capabilities & ENE_FW2_FAN_AS_NRML_IN);
+
+	ene_printk(KERN_NOTICE, "hardware features:\n");
+	ene_printk(KERN_NOTICE,
+		"learning and transmit %s, gpio40_learn %s, fan_in %s\n",
+	       dev->hw_learning_and_tx_capable ? "on" : "off",
+	       dev->hw_gpio40_learning ? "on" : "off",
+	       dev->hw_fan_as_normal_input ? "on" : "off");
+
+	if (dev->hw_learning_and_tx_capable) {
+		ene_printk(KERN_WARNING,
+		"Device supports transmitting, but that support is\n");
+		ene_printk(KERN_WARNING,
+		"lightly tested. Please test it and mail\n");
+		ene_printk(KERN_WARNING,
+		"[email protected]\n");
+	}
+	return 0;
+}
+
+/* this enables/disables IR input via gpio40*/
+static void ene_enable_gpio40_recieve(struct ene_device *dev, int enable)
+{
+	ene_hw_write_reg_mask(dev, ENE_CIR_CONF2, enable ?
+			      0 : ENE_CIR_CONF2_GPIO40DIS,
+			      ENE_CIR_CONF2_GPIO40DIS);
+}
+
+/* this enables/disables IR via standard input */
+static void ene_enable_normal_recieve(struct ene_device *dev, int enable)
+{
+	ene_hw_write_reg(dev, ENE_CIR_CONF1, enable ? ENE_CIR_CONF1_RX_ON : 0);
+}
+
+/* this enables/disables IR input via unused fan tachtometer input */
+static void ene_enable_fan_recieve(struct ene_device *dev, int enable)
+{
+	if (!enable)
+		ene_hw_write_reg(dev, ENE_FAN_AS_IN1, 0);
+	else {
+		ene_hw_write_reg(dev, ENE_FAN_AS_IN1, ENE_FAN_AS_IN1_EN);
+		ene_hw_write_reg(dev, ENE_FAN_AS_IN2, ENE_FAN_AS_IN2_EN);
+	}
+	dev->rx_fan_input_inuse = enable;
+}
+
+
+/* Sense current recieved carrier */
+static int ene_rx_sense_carrier(struct ene_device *dev)
+{
+	int period = ene_hw_read_reg(dev, ENE_RX_CARRIER);
+	int carrier;
+	ene_dbg("RX: hardware carrier period = %02x", period);
+
+	if (!(period & ENE_RX_CARRIER_VALID))
+		return 0;
+
+	period &= ~ENE_RX_CARRIER_VALID;
+
+	if (!period)
+		return 0;
+
+	carrier = 2000000 / period;
+	ene_dbg("RX: sensed carrier = %d Hz", carrier);
+	return carrier;
+}
+
+/* determine which input to use*/
+static void ene_rx_set_inputs(struct ene_device *dev)
+{
+	int learning_mode = dev->learning_enabled || dev->rx_carrier_sense;
+
+	ene_dbg("RX: setup reciever, learning mode = %d", learning_mode);
+
+	ene_enable_normal_recieve(dev, 1);
+
+	/* old hardware doesn't support learning mode for sure */
+	if (dev->hw_revision <= ENE_HW_B)
+		return;
+
+	/* reciever not learning capable, still set gpio40 correctly */
+	if (!dev->hw_learning_and_tx_capable) {
+		ene_enable_gpio40_recieve(dev, !dev->hw_gpio40_learning);
+		return;
+	}
+
+	/* enable learning mode */
+	if (learning_mode) {
+		ene_enable_gpio40_recieve(dev, dev->hw_gpio40_learning);
+
+		/* fan input is not used for learning */
+		if (dev->hw_fan_as_normal_input)
+			ene_enable_fan_recieve(dev, 0);
+
+	/* disable learning mode */
+	} else {
+		if (dev->hw_fan_as_normal_input) {
+			ene_enable_fan_recieve(dev, 1);
+			ene_enable_normal_recieve(dev, 0);
+		} else
+			ene_enable_gpio40_recieve(dev,
+					!dev->hw_gpio40_learning);
+	}
+
+	/* set few additional settings for this mode */
+	ene_hw_write_reg_mask(dev, ENE_CIR_CONF1, learning_mode ?
+			      ENE_CIR_CONF1_LEARN1 : 0, ENE_CIR_CONF1_LEARN1);
+
+	ene_hw_write_reg_mask(dev, ENE_CIR_CONF2, learning_mode ?
+			      ENE_CIR_CONF2_LEARN2 : 0, ENE_CIR_CONF2_LEARN2);
+}
+
+/* Enable the device for receive */
+static void ene_rx_enable(struct ene_device *dev)
+{
+	u8 reg_value;
+
+	if (dev->hw_revision < ENE_HW_C) {
+		ene_hw_write_reg(dev, ENEB_IRQ, dev->irq << 1);
+		ene_hw_write_reg(dev, ENEB_IRQ_UNK1, 0x01);
+	} else {
+		reg_value = ene_hw_read_reg(dev, ENEC_IRQ) & 0xF0;
+		reg_value |= ENEC_IRQ_UNK_EN;
+		reg_value &= ~ENEC_IRQ_STATUS;
+		reg_value |= (dev->irq & ENEC_IRQ_MASK);
+		ene_hw_write_reg(dev, ENEC_IRQ, reg_value);
+		ene_hw_write_reg(dev, ENE_TX_UNK1, 0x63);
+	}
+
+	ene_hw_write_reg(dev, ENE_CIR_CONF2, 0x00);
+	ene_rx_set_inputs(dev);
+
+	/* set sampling period */
+	ene_hw_write_reg(dev, ENE_CIR_SAMPLE_PERIOD, sample_period);
+
+	/* ack any pending irqs - just in case */
+	ene_irq_status(dev);
+
+	/* enter idle mode */
+	ene_rx_set_idle(dev, 1);
+
+	/* enable firmware bits */
+	ene_hw_write_reg_mask(dev, ENE_FW1,
+			      ENE_FW1_ENABLE | ENE_FW1_IRQ,
+			      ENE_FW1_ENABLE | ENE_FW1_IRQ);
+}
+
+/* Disable the device reciever */
+static void ene_rx_disable(struct ene_device *dev)
+{
+	/* disable inputs */
+	ene_enable_normal_recieve(dev, 0);
+
+	if (dev->hw_fan_as_normal_input)
+		ene_enable_fan_recieve(dev, 0);
+
+	/* disable hardware IRQ and firmware flag */
+	ene_hw_write_reg_mask(dev, ENE_FW1, 0, ENE_FW1_ENABLE | ENE_FW1_IRQ);
+
+	ene_rx_set_idle(dev, 1);
+}
+
+/*  send current sample to the user */
+static void ene_rx_flush(struct ene_device *dev, int timeout)
+{
+	unsigned long value;
+
+	value =	dev->rx_sample_pulse ? LIRC_PULSE(dev->rx_sample) :
+					LIRC_SPACE(dev->rx_sample);
+	ene_send_sample(dev, value);
+	dev->rx_sample = 0;
+	dev->rx_sample_pulse = 0;
+}
+
+/* recieve new sample and process it */
+static void ene_rx_sample(struct ene_device *dev, int sample, int is_pulse)
+{
+	ene_dbg("RX: sample %8d (%s)", sample, is_pulse ? "pulse" : "space");
+
+	/* ignore spaces in idle mode, can get them on revC */
+	/* also ignore a space in front of first pulse */
+	if (dev->rx_idle && !is_pulse)
+		return;
+
+	/* get out of idle mode now */
+	if (dev->rx_idle)
+		ene_rx_set_idle(dev, 0);
+
+	if (!dev->rx_sample) {
+		dev->rx_sample = sample;
+		dev->rx_sample_pulse = is_pulse;
+	} else if (is_pulse == dev->rx_sample_pulse)
+		dev->rx_sample += sample;
+	else {
+		ene_rx_flush(dev, 0);
+		dev->rx_sample = sample;
+		dev->rx_sample_pulse = is_pulse;
+	}
+
+	if (is_pulse)
+		return;
+
+	/* overflow sample from fan input recieved, enable idle mode */
+	if (dev->rx_fan_input_inuse &&
+		sample == ENE_FAN_VALUE_MASK * ENE_SAMPLE_PERIOD_FAN) {
+		ene_rx_set_idle(dev, 1);
+		return;
+	}
+
+	if (!dev->rx_fan_input_inuse) {
+		/* Report timeout if enabled */
+		if (dev->rx_timeout && dev->rx_send_timeout_packet &&
+			!dev->rx_timeout_sent &&
+				dev->rx_sample > dev->rx_timeout) {
+			ene_dbg("RX: sending timeout sample");
+			ene_send_sample(dev, LIRC_TIMEOUT(dev->rx_sample));
+			dev->rx_timeout_sent = 1;
+		}
+
+		/* too large sample accumulated via normal input.
+		note that on revC, hardware idle mode turns on automaticly,
+			so max gap should be less that the gap after which
+			hw stops sending samples */
+		if (dev->rx_sample > ENE_MAXGAP) {
+			ene_rx_set_idle(dev, 1);
+			return;
+		}
+	}
+}
+
+/* enable or disable idle mode */
+static void ene_rx_set_idle(struct ene_device *dev, int idle)
+{
+	struct timeval now;
+	int disable_sampler = 0;
+
+
+	/* Also put hardware sampler in 'idle' mode on revB*/
+	/* revC and higher do that automaticly (firmware does?) */
+	if ((dev->hw_revision < ENE_HW_C) && enable_idle)
+		if (idle)
+			disable_sampler = 1;
+
+	ene_hw_write_reg_mask(dev, ENE_CIR_SAMPLE_PERIOD,
+			      disable_sampler ? 0 : ENE_CIR_SAMPLE_OVERFLOW,
+			      ENE_CIR_SAMPLE_OVERFLOW);
+	dev->rx_idle = idle;
+
+	/* remember when we have entered the idle mode */
+	if (idle) {
+		ene_dbg("RX: going into idle mode");
+		do_gettimeofday(&dev->rx_gap_start);
+		return;
+	}
+
+	ene_dbg("RX: back from idle mode");
+
+	/* send the gap between keypresses now */
+	do_gettimeofday(&now);
+
+	if (dev->rx_sample_pulse) {
+		ene_dbg("RX: somehow we recieved a pulse before idle mode???");
+		return;
+	}
+
+	/* manually calculate and recieve the gap between keypresses */
+	if (now.tv_sec - dev->rx_gap_start.tv_sec > 16)
+		dev->rx_sample = LIRC_SPACE(LIRC_VALUE_MASK);
+	else
+		dev->rx_sample +=
+		    1000000ull * (now.tv_sec - dev->rx_gap_start.tv_sec)
+		    + now.tv_usec - dev->rx_gap_start.tv_usec;
+
+	if (dev->rx_sample > LIRC_SPACE(LIRC_VALUE_MASK))
+		dev->rx_sample = LIRC_SPACE(LIRC_VALUE_MASK);
+
+	ene_rx_flush(dev, 0);
+	dev->rx_timeout_sent = 0;
+}
+
+/* prepare transmission */
+static void ene_tx_prepare(struct ene_device *dev)
+{
+	u8 conf1;
+
+	conf1 = ene_hw_read_reg(dev, ENE_CIR_CONF1);
+	dev->saved_conf1 = conf1;
+
+	if (dev->hw_revision == ENE_HW_C)
+		conf1 &= ~ENE_CIR_CONF1_TX_CLEAR;
+
+	/* Enable TX engine */
+	conf1 |= ENE_CIR_CONF1_TX_ON;
+
+	/* Set carrier */
+	if (dev->tx_period) {
+
+		int tx_period_in500ns = dev->tx_period * 2;
+
+		int tx_pulse_width_in_500ns =
+			tx_period_in500ns / (100 / dev->tx_duty_cycle);
+
+		if (!tx_pulse_width_in_500ns)
+			tx_pulse_width_in_500ns = 1;
+
+		ene_dbg("TX: pulse distance = %d * 500 ns", tx_period_in500ns);
+		ene_dbg("TX: pulse width = %d * 500 ns",
+						tx_pulse_width_in_500ns);
+
+		ene_hw_write_reg(dev, ENE_TX_PERIOD, ENE_TX_PERIOD_UNKBIT |
+					tx_period_in500ns);
+
+		ene_hw_write_reg(dev, ENE_TX_PERIOD_PULSE,
+					tx_pulse_width_in_500ns);
+
+		conf1 |= ENE_CIR_CONF1_TX_CARR;
+	} else
+		conf1 &= ~ENE_CIR_CONF1_TX_CARR;
+
+	ene_hw_write_reg(dev, ENE_CIR_CONF1, conf1);
+	dev->tx_underway = 1;
+
+}
+
+/* end transmission */
+static void ene_tx_complete(struct ene_device *dev)
+{
+	ene_hw_write_reg(dev, ENE_CIR_CONF1, dev->saved_conf1);
+	dev->tx_underway = 0;
+}
+
+/* set transmit mask */
+static void ene_tx_set_transmiter_mask(struct ene_device *dev)
+{
+	u8 txport1 = ene_hw_read_reg(dev, ENE_TX_PORT1) & ~ENE_TX_PORT1_EN;
+	u8 txport2 = ene_hw_read_reg(dev, ENE_TX_PORT2) & ~ENE_TX_PORT2_EN;
+
+	if (dev->transmitter_mask & 0x01)
+		txport1 |= ENE_TX_PORT1_EN;
+
+	if (dev->transmitter_mask & 0x02)
+		txport2 |= ENE_TX_PORT2_EN;
+
+	ene_hw_write_reg(dev, ENE_TX_PORT1, txport1);
+	ene_hw_write_reg(dev, ENE_TX_PORT2, txport2);
+}
+
+/* TX one sample - must be called with dev->hw_lock*/
+static void ene_tx_sample(struct ene_device *dev)
+{
+	u8 raw_tx;
+	u32 sample;
+
+	if (!dev->tx_underway) {
+		ene_dbg("TX: attempt to transmit while hw isn't setup");
+		return;
+	}
+
+	/* Grab next TX sample */
+	if (!dev->tx_sample) {
+again:
+		if (dev->tx_pos == dev->tx_len + 1) {
+			if (!dev->tx_done) {
+				ene_dbg("TX: no more data to send");
+				dev->tx_done = 1;
+				goto exit;
+			} else {
+				ene_dbg("TX: last sample sent by hardware");
+				ene_tx_complete(dev);
+				complete(&dev->tx_complete);
+				return;
+			}
+		}
+
+		sample = dev->tx_buffer[dev->tx_pos++];
+		dev->tx_sample_pulse = !dev->tx_sample_pulse;
+
+		ene_dbg("TX: sample %8d (%s)", sample, dev->tx_sample_pulse ?
+							"pulse" : "space");
+
+		dev->tx_sample = DIV_ROUND_CLOSEST(sample, ENE_TX_SMPL_PERIOD);
+
+		/* guard against too short samples */
+		if (!dev->tx_sample)
+			goto again;
+	}
+
+	raw_tx = min(dev->tx_sample , (unsigned int)ENE_TX_SMLP_MASK);
+	dev->tx_sample -= raw_tx;
+
+	if (dev->tx_sample_pulse)
+		raw_tx |= ENE_TX_PULSE_MASK;
+
+	ene_hw_write_reg(dev, ENE_TX_INPUT1 + dev->tx_reg, raw_tx);
+	dev->tx_reg = !dev->tx_reg;
+exit:
+	/* simulate TX done interrupt */
+	if (txsim)
+		mod_timer(&dev->tx_sim_timer, jiffies + HZ / 500);
+}
+
+/* timer to simulate tx done interrupt */
+static void ene_tx_irqsim(unsigned long data)
+{
+	struct ene_device *dev = (struct ene_device *)data;
+	unsigned long flags;
+
+	spin_lock_irqsave(&dev->hw_lock, flags);
+	ene_tx_sample(dev);
+	spin_unlock_irqrestore(&dev->hw_lock, flags);
+}
+
+
+/* read irq status and ack it */
+static int ene_irq_status(struct ene_device *dev)
+{
+	u8 irq_status;
+	u8 fw_flags1, fw_flags2;
+	int cur_rx_pointer;
+	int retval = 0;
+
+	fw_flags2 = ene_hw_read_reg(dev, ENE_FW2);
+	cur_rx_pointer = !!(fw_flags2 & ENE_FW2_BUF_HIGH);
+
+	if (dev->hw_revision < ENE_HW_C) {
+		irq_status = ene_hw_read_reg(dev, ENEB_IRQ_STATUS);
+
+		if (!(irq_status & ENEB_IRQ_STATUS_IR))
+			return 0;
+
+		ene_hw_write_reg(dev, ENEB_IRQ_STATUS,
+				 irq_status & ~ENEB_IRQ_STATUS_IR);
+		dev->rx_pointer = cur_rx_pointer;
+		return ENE_IRQ_RX;
+	}
+
+	irq_status = ene_hw_read_reg(dev, ENEC_IRQ);
+
+	if (!(irq_status & ENEC_IRQ_STATUS))
+		return 0;
+
+	/* original driver does that twice - a workaround ? */
+	ene_hw_write_reg(dev, ENEC_IRQ, irq_status & ~ENEC_IRQ_STATUS);
+	ene_hw_write_reg(dev, ENEC_IRQ, irq_status & ~ENEC_IRQ_STATUS);
+
+	/* clear unknown flag in F8F9 */
+	if (fw_flags2 & ENE_FW2_IRQ_CLR)
+		ene_hw_write_reg(dev, ENE_FW2, fw_flags2 & ~ENE_FW2_IRQ_CLR);
+
+	/* check if this is a TX interrupt */
+	fw_flags1 = ene_hw_read_reg(dev, ENE_FW1);
+	if (fw_flags1 & ENE_FW1_TXIRQ) {
+		ene_hw_write_reg(dev, ENE_FW1, fw_flags1 & ~ENE_FW1_TXIRQ);
+		retval |= ENE_IRQ_TX;
+	}
+
+	/* Check if this is RX interrupt */
+	if (dev->rx_pointer != cur_rx_pointer) {
+		retval |= ENE_IRQ_RX;
+		dev->rx_pointer = cur_rx_pointer;
+
+	} else if (!(retval & ENE_IRQ_TX)) {
+		ene_dbg("RX: interrupt without change in RX pointer(%d)",
+			dev->rx_pointer);
+		retval |= ENE_IRQ_RX;
+	}
+
+	if ((retval & ENE_IRQ_RX) && (retval & ENE_IRQ_TX))
+		ene_dbg("both RX and TX interrupt at same time");
+
+	return retval;
+}
+
+/* interrupt handler */
+static irqreturn_t ene_isr(int irq, void *data)
+{
+	u16 hw_value;
+	int i, hw_sample;
+	int pulse;
+	int irq_status;
+	unsigned long flags;
+	int carrier = 0;
+	irqreturn_t retval = IRQ_NONE;
+	struct ene_device *dev = (struct ene_device *)data;
+
+
+	spin_lock_irqsave(&dev->hw_lock, flags);
+	irq_status = ene_irq_status(dev);
+
+	if (!irq_status)
+		goto unlock;
+
+	retval = IRQ_HANDLED;
+
+	if (irq_status & ENE_IRQ_TX) {
+
+		if (!dev->hw_learning_and_tx_capable) {
+			ene_dbg("TX interrupt on unsupported device!");
+			goto unlock;
+		}
+		ene_tx_sample(dev);
+	}
+
+	if (!(irq_status & ENE_IRQ_RX))
+		goto unlock;
+
+
+	if ((debug && dev->learning_enabled) || dev->rx_carrier_sense)
+		carrier = ene_rx_sense_carrier(dev);
+
+	if (dev->rx_carrier_sense && carrier)
+		ene_send_sample(dev, LIRC_FREQUENCY(carrier));
+
+
+	for (i = 0; i < ENE_SAMPLES_SIZE; i++) {
+		hw_value = ene_hw_read_reg(dev,
+				ENE_SAMPLE_BUFFER + dev->rx_pointer * 4 + i);
+
+		if (dev->rx_fan_input_inuse) {
+			/* read high part of the sample */
+			hw_value |= ene_hw_read_reg(dev,
+			    ENE_SAMPLE_BUFFER_FAN +
+					dev->rx_pointer * 4 + i) << 8;
+			pulse = hw_value & ENE_FAN_SMPL_PULS_MSK;
+
+			/* clear space bit, and other unused bits */
+			hw_value &= ENE_FAN_VALUE_MASK;
+			hw_sample = hw_value * ENE_SAMPLE_PERIOD_FAN;
+
+		} else {
+			pulse = !(hw_value & ENE_SAMPLE_SPC_MASK);
+			hw_value &= ENE_SAMPLE_VALUE_MASK;
+			hw_sample = hw_value * sample_period;
+		}
+		/* no more data */
+		if (!(hw_value))
+			break;
+
+		ene_rx_sample(dev, hw_sample, pulse);
+	}
+unlock:
+	spin_unlock_irqrestore(&dev->hw_lock, flags);
+	return retval;
+}
+
+/* Initialize default settings */
+static void ene_setup_settings(struct ene_device *dev)
+{
+	dev->rx_send_timeout_packet = 0;
+	dev->rx_timeout = ENE_MAXGAP;
+	dev->tx_period = 32;
+	dev->tx_duty_cycle = 25; /*%*/
+	dev->transmitter_mask = 3;
+
+	/* Force learning mode if (input == 2), otherwise
+		let user set it with LIRC_SET_REC_CARRIER */
+	dev->learning_enabled =
+		(input == 2 && dev->hw_learning_and_tx_capable);
+
+	/* Clear accumulated sample bufer */
+	dev->rx_sample = 0;
+	dev->rx_sample_pulse = 0;
+	dev->rx_pointer = -1;
+	dev->rx_carrier_sense = 0;
+
+}
+
+/* outside interface: called on first open*/
+static int ene_open(void *data)
+{
+	struct ene_device *dev = (struct ene_device *)data;
+	unsigned long flags;
+
+	spin_lock_irqsave(&dev->hw_lock, flags);
+	dev->in_use = 1;
+	ene_setup_settings(dev);
+	ene_rx_enable(dev);
+	spin_unlock_irqrestore(&dev->hw_lock, flags);
+	return 0;
+}
+
+/* outside interface: called on device close*/
+static void ene_close(void *data)
+{
+	struct ene_device *dev = (struct ene_device *)data;
+	unsigned long flags;
+	spin_lock_irqsave(&dev->hw_lock, flags);
+
+	ene_rx_disable(dev);
+	dev->in_use = 0;
+	spin_unlock_irqrestore(&dev->hw_lock, flags);
+}
+
+/* outside interface for settings */
+static int ene_ioctl(struct inode *node, struct file *file,
+		      unsigned int cmd, unsigned long arg)
+{
+	int lvalue = 0, retval, tmp;
+	unsigned long flags;
+	struct ene_device *dev = lirc_get_pdata(file);
+
+
+	switch (cmd) {
+	case LIRC_SET_SEND_CARRIER:
+	case LIRC_SET_SEND_DUTY_CYCLE:
+	case LIRC_SET_TRANSMITTER_MASK:
+	case LIRC_SET_MEASURE_CARRIER_MODE:
+	case LIRC_SET_REC_CARRIER:
+		/* All these aren't possible without this */
+		if (!dev->hw_learning_and_tx_capable)
+			return -ENOSYS;
+		/* Fall through */
+	case LIRC_SET_REC_TIMEOUT:
+	case LIRC_SET_REC_TIMEOUT_REPORTS:
+		retval = get_user(lvalue, (unsigned int *) arg);
+		if (retval)
+			return retval;
+	}
+
+	switch (cmd) {
+	case LIRC_SET_SEND_CARRIER:
+		ene_dbg("TX: attempt to set tx carrier to %d kHz", lvalue);
+		tmp = 1000000 / lvalue; /* (1 / freq) (* # usec in 1 sec) */
+
+		if (tmp && (tmp > ENE_TX_PERIOD_MAX ||
+				tmp < ENE_TX_PERIOD_MIN)) {
+
+			ene_dbg("TX: out of range %d-%d carrier, "
+				"falling back to 32 kHz",
+				1000 / ENE_TX_PERIOD_MIN,
+				1000 / ENE_TX_PERIOD_MAX);
+
+			tmp = 32; /* this is just a coincidence!!! */
+		}
+		ene_dbg("TX: set carrier to %d kHz", lvalue);
+
+		spin_lock_irqsave(&dev->hw_lock, flags);
+		dev->tx_period = tmp;
+		spin_unlock_irqrestore(&dev->hw_lock, flags);
+		break;
+	case LIRC_SET_SEND_DUTY_CYCLE:
+		ene_dbg("TX: attempt to set duty cycle to %d%%", lvalue);
+
+		if ((lvalue >= 100) || (lvalue <= 0)) {
+			retval = -EINVAL;
+			break;
+		}
+		spin_lock_irqsave(&dev->hw_lock, flags);
+		dev->tx_duty_cycle = lvalue;
+		spin_unlock_irqrestore(&dev->hw_lock, flags);
+		break;
+	case LIRC_SET_TRANSMITTER_MASK:
+		ene_dbg("TX: attempt to set transmitter mask %02x", lvalue);
+
+		/* invalid txmask */
+		if (!lvalue || lvalue & ~0x3) {
+			ene_dbg("TX: invalid mask");
+			/* this supposed to return num of transmitters */
+			retval =  2;
+			break;
+		}
+		spin_lock_irqsave(&dev->hw_lock, flags);
+		dev->transmitter_mask = lvalue;
+		spin_unlock_irqrestore(&dev->hw_lock, flags);
+		break;
+	case LIRC_SET_REC_CARRIER:
+		tmp = (lvalue > ENE_NORMAL_RX_HI || lvalue < ENE_NORMAL_RX_LOW);
+
+		if (tmp != dev->learning_enabled) {
+			spin_lock_irqsave(&dev->hw_lock, flags);
+			dev->learning_enabled = tmp;
+			ene_rx_set_inputs(dev);
+			spin_unlock_irqrestore(&dev->hw_lock, flags);
+		}
+		break;
+	case LIRC_SET_REC_TIMEOUT:
+		spin_lock_irqsave(&dev->hw_lock, flags);
+		dev->rx_timeout = lvalue;
+		spin_unlock_irqrestore(&dev->hw_lock, flags);
+		ene_dbg("RX: set rx report timeout to %d", dev->rx_timeout);
+		break;
+	case LIRC_SET_REC_TIMEOUT_REPORTS:
+		spin_lock_irqsave(&dev->hw_lock, flags);
+		dev->rx_send_timeout_packet = lvalue;
+		spin_unlock_irqrestore(&dev->hw_lock, flags);
+		ene_dbg("RX: %sable timeout reports",
+				dev->rx_send_timeout_packet ? "en" : "dis");
+		break;
+	case LIRC_SET_MEASURE_CARRIER_MODE:
+		if (dev->rx_carrier_sense == lvalue)
+			break;
+		spin_lock_irqsave(&dev->hw_lock, flags);
+		dev->rx_carrier_sense = lvalue;
+		ene_rx_set_inputs(dev);
+		spin_unlock_irqrestore(&dev->hw_lock, flags);
+		break;
+	case LIRC_GET_REC_RESOLUTION:
+		tmp = dev->rx_fan_input_inuse ?
+			ENE_SAMPLE_PERIOD_FAN : sample_period;
+		retval = put_user(tmp, (unsigned long *) arg);
+		break;
+	default:
+		retval = -ENOIOCTLCMD;
+		break;
+	}
+
+	return retval;
+}
+
+/* outside interface: transmit */
+static ssize_t ene_transmit(struct file *file, const char *buf,
+				  size_t n, loff_t *ppos)
+{
+	struct ene_device *dev = lirc_get_pdata(file);
+	unsigned long flags;
+
+	if (!dev)
+		return -EFAULT;
+
+	if (!dev->hw_learning_and_tx_capable)
+		return -ENODEV;
+
+	if (n % sizeof(int))
+		return -EINVAL;
+
+	if (n > ENE_TXBUF_SIZE * sizeof(int))
+		return -ENOMEM;
+
+	if (copy_from_user(dev->tx_buffer, buf, n))
+		return -EFAULT;
+
+	dev->tx_len = n / sizeof(int);
+	dev->tx_pos = 0;
+	dev->tx_reg = 0;
+	dev->tx_done = 0;
+	dev->tx_sample = 0;
+	dev->tx_sample_pulse = 0;
+
+	ene_dbg("TX: %d samples", dev->tx_len);
+
+	spin_lock_irqsave(&dev->hw_lock, flags);
+
+	ene_tx_set_transmiter_mask(dev);
+	ene_tx_prepare(dev);
+
+	/* Transmit first two samples */
+	ene_tx_sample(dev);
+	ene_tx_sample(dev);
+
+	spin_unlock_irqrestore(&dev->hw_lock, flags);
+
+	if (wait_for_completion_timeout(&dev->tx_complete, 2 * HZ) == 0) {
+		ene_dbg("TX: timeout");
+		spin_lock_irqsave(&dev->hw_lock, flags);
+		ene_tx_complete(dev);
+		spin_unlock_irqrestore(&dev->hw_lock, flags);
+	} else
+		ene_dbg("TX: done");
+
+	return n;
+}
+
+/* Sends one sample to the user */
+static void ene_send_sample(struct ene_device *dev, unsigned long sample)
+{
+	if (!lirc_buffer_full(dev->lirc_driver->rbuf)) {
+		lirc_buffer_write(dev->lirc_driver->rbuf, (void *)&sample);
+		wake_up(&dev->lirc_driver->rbuf->wait_poll);
+	}
+}
+
+
+static const struct file_operations ene_fops = {
+	.owner		= THIS_MODULE,
+	.write		= ene_transmit,
+	.ioctl		= ene_ioctl,
+};
+
+/* main load function */
+static int ene_probe(struct pnp_dev *pnp_dev,
+		     const struct pnp_device_id *dev_id)
+{
+	struct ene_device *dev;
+	struct lirc_driver *lirc_driver;
+	int error = -ENOMEM;
+
+	dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
+
+	if (!dev)
+		goto err1;
+
+	dev->pnp_dev = pnp_dev;
+	pnp_set_drvdata(pnp_dev, dev);
+
+	/* prepare lirc interface */
+	error = -ENOMEM;
+	lirc_driver = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL);
+
+	if (!lirc_driver)
+		goto err2;
+
+	dev->lirc_driver = lirc_driver;
+
+	strcpy(lirc_driver->name, ENE_DRIVER_NAME);
+	lirc_driver->minor = -1;
+	lirc_driver->code_length = sizeof(int) * 8;
+	lirc_driver->features = LIRC_CAN_REC_MODE2 |
+				LIRC_CAN_GET_REC_RESOLUTION |
+				LIRC_CAN_SET_REC_TIMEOUT;
+	lirc_driver->data = dev;
+	lirc_driver->set_use_inc = ene_open;
+	lirc_driver->set_use_dec = ene_close;
+	lirc_driver->dev = &pnp_dev->dev;
+	lirc_driver->owner = THIS_MODULE;
+	lirc_driver->fops = &ene_fops;
+	lirc_driver->min_timeout = ENE_MINGAP;
+	lirc_driver->max_timeout = ENE_MAXGAP;
+	lirc_driver->rbuf = kzalloc(sizeof(struct lirc_buffer), GFP_KERNEL);
+
+	if (!lirc_driver->rbuf)
+		goto err3;
+
+	if (lirc_buffer_init(lirc_driver->rbuf, sizeof(int), sizeof(int) * 512))
+		goto err4;
+
+	/* validate resources */
+	if (!pnp_port_valid(pnp_dev, 0) ||
+	    pnp_port_len(pnp_dev, 0) < ENE_MAX_IO)
+		goto err5;
+
+	if (!pnp_irq_valid(pnp_dev, 0))
+		goto err5;
+
+	dev->hw_io = pnp_port_start(pnp_dev, 0);
+	dev->irq = pnp_irq(pnp_dev, 0);
+	spin_lock_init(&dev->hw_lock);
+
+	/* claim the resources */
+	error = -EBUSY;
+	if (!request_region(dev->hw_io, ENE_MAX_IO, ENE_DRIVER_NAME))
+		goto err5;
+
+	if (request_irq(dev->irq, ene_isr,
+			IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev))
+		goto err6;
+
+	/* detect hardware version and features */
+	error = ene_hw_detect(dev);
+	if (error)
+		goto err7;
+
+	ene_setup_settings(dev);
+
+	if (!dev->hw_learning_and_tx_capable && txsim) {
+		dev->hw_learning_and_tx_capable = 1;
+		setup_timer(&dev->tx_sim_timer, ene_tx_irqsim,
+						(long unsigned int)dev);
+		ene_printk(KERN_WARNING,
+			"Simulation of TX activated\n");
+	}
+
+	if (dev->hw_learning_and_tx_capable) {
+		lirc_driver->features |= LIRC_CAN_SEND_PULSE |
+					 LIRC_CAN_SET_SEND_CARRIER |
+					 LIRC_CAN_SET_TRANSMITTER_MASK;
+
+		if (enable_duty_carrier)
+			lirc_driver->features |= LIRC_CAN_SET_SEND_DUTY_CYCLE;
+
+		if (input == 0)
+			lirc_driver->features |= LIRC_CAN_SET_REC_CARRIER;
+
+		init_completion(&dev->tx_complete);
+	}
+
+	/* don't allow too short/long sample periods */
+	if (sample_period < 5 || sample_period > 0x7F)
+		sample_period = -1;
+
+	/* choose default sample period */
+	if (sample_period == -1) {
+
+		sample_period = 50;
+
+		/* on revB, hardware idle mode eats first sample
+		  if we set too low sample period */
+		if (dev->hw_revision == ENE_HW_B && enable_idle)
+			sample_period = 75;
+	}
+
+	device_set_wakeup_capable(&pnp_dev->dev, 1);
+	device_set_wakeup_enable(&pnp_dev->dev, 1);
+
+	error = -ENODEV;
+	if (lirc_register_driver(lirc_driver))
+		goto err7;
+
+	ene_printk(KERN_NOTICE, "driver has been succesfully loaded\n");
+	return 0;
+
+err7:
+	free_irq(dev->irq, dev);
+err6:
+	release_region(dev->hw_io, ENE_MAX_IO);
+err5:
+	lirc_buffer_free(lirc_driver->rbuf);
+err4:
+	kfree(lirc_driver->rbuf);
+err3:
+	kfree(lirc_driver);
+err2:
+	kfree(dev);
+err1:
+	return error;
+}
+
+/* main unload function */
+static void ene_remove(struct pnp_dev *pnp_dev)
+{
+	struct ene_device *dev = pnp_get_drvdata(pnp_dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&dev->hw_lock, flags);
+	ene_rx_disable(dev);
+	spin_unlock_irqrestore(&dev->hw_lock, flags);
+
+	free_irq(dev->irq, dev);
+	release_region(dev->hw_io, ENE_MAX_IO);
+	lirc_unregister_driver(dev->lirc_driver->minor);
+	lirc_buffer_free(dev->lirc_driver->rbuf);
+	kfree(dev->lirc_driver);
+	kfree(dev);
+}
+
+/* enable wake on IR (wakes on specific button on original remote) */
+static void ene_enable_wake(struct ene_device *dev, int enable)
+{
+	enable = enable && device_may_wakeup(&dev->pnp_dev->dev);
+
+	ene_dbg("wake on IR %s", enable ? "enabled" : "disabled");
+
+	ene_hw_write_reg_mask(dev, ENE_FW1, enable ?
+		ENE_FW1_WAKE : 0, ENE_FW1_WAKE);
+}
+
+#ifdef CONFIG_PM
+static int ene_suspend(struct pnp_dev *pnp_dev, pm_message_t state)
+{
+	struct ene_device *dev = pnp_get_drvdata(pnp_dev);
+	ene_enable_wake(dev, 1);
+	return 0;
+}
+
+static int ene_resume(struct pnp_dev *pnp_dev)
+{
+	struct ene_device *dev = pnp_get_drvdata(pnp_dev);
+	if (dev->in_use)
+		ene_rx_enable(dev);
+
+	ene_enable_wake(dev, 0);
+	return 0;
+}
+#endif
+
+static void ene_shutdown(struct pnp_dev *pnp_dev)
+{
+	struct ene_device *dev = pnp_get_drvdata(pnp_dev);
+	ene_enable_wake(dev, 1);
+}
+
+static const struct pnp_device_id ene_ids[] = {
+	{.id = "ENE0100",},
+	{.id = "ENE0200",},
+	{.id = "ENE0201",},
+	{},
+};
+
+static struct pnp_driver ene_driver = {
+	.name = ENE_DRIVER_NAME,
+	.id_table = ene_ids,
+	.flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
+
+	.probe = ene_probe,
+	.remove = __devexit_p(ene_remove),
+#ifdef CONFIG_PM
+	.suspend = ene_suspend,
+	.resume = ene_resume,
+#endif
+	.shutdown = ene_shutdown,
+};
+
+static int __init ene_init(void)
+{
+	return pnp_register_driver(&ene_driver);
+}
+
+static void ene_exit(void)
+{
+	pnp_unregister_driver(&ene_driver);
+}
+
+module_param(sample_period, int, S_IRUGO);
+MODULE_PARM_DESC(sample_period, "Hardware sample period (50 us default)");
+
+module_param(enable_idle, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(enable_idle,
+	"Enables turning off signal sampling after long inactivity time; "
+	"if disabled might help detecting input signal (default: enabled)"
+	" (KB3926B only)");
+
+module_param(input, bool, S_IRUGO);
+MODULE_PARM_DESC(input, "select which input to use "
+	"0 - auto, 1 - standard, 2 - wideband(KB3926C+)");
+
+module_param(debug, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, "Enable debug (debug=2 verbose debug output)");
+
+module_param(txsim, bool, S_IRUGO);
+MODULE_PARM_DESC(txsim,
+	"Simulate TX features on unsupported hardware (dangerous)");
+
+module_param(enable_duty_carrier, bool, S_IRUGO);
+MODULE_PARM_DESC(enable_duty_carrier,
+	"Enable a code that might allow to to set TX carrier duty cycle");
+
+MODULE_DEVICE_TABLE(pnp, ene_ids);
+MODULE_DESCRIPTION
+	("LIRC driver for KB3926B/KB3926C/KB3926D "
+	"(aka ENE0100/ENE0200/ENE0201) CIR port");
+
+MODULE_AUTHOR("Maxim Levitsky");
+MODULE_LICENSE("GPL");
+
+module_init(ene_init);
+module_exit(ene_exit);
drivers/media/IR/ene_ir.h new file +240 -0

240 lines not on this page · raw message

drivers/staging/lirc/Kconfig +0 -8
index 968c2ad..d199165 100644
@@ -17,14 +17,6 @@ config LIRC_BT829
 	help
 	  Driver for the IR interface on BT829-based hardware
 
-config LIRC_ENE0100
-	tristate "ENE KB3924/ENE0100 CIR Port Reciever"
-	depends on LIRC_STAGING
-	help
-	  This is a driver for CIR port handled by ENE KB3924 embedded
-	  controller found on some notebooks.
-	  It appears on PNP list as ENE0100.
-
 config LIRC_I2C
 	tristate "I2C Based IR Receivers"
 	depends on LIRC_STAGING
drivers/staging/lirc/Makefile +0 -1
index a019182..7011d6c 100644
@@ -4,7 +4,6 @@
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_LIRC_BT829)	+= lirc_bt829.o
-obj-$(CONFIG_LIRC_ENE0100)	+= lirc_ene0100.o
 obj-$(CONFIG_LIRC_I2C)		+= lirc_i2c.o
 obj-$(CONFIG_LIRC_IGORPLUGUSB)	+= lirc_igorplugusb.o
 obj-$(CONFIG_LIRC_IMON)		+= lirc_imon.o
drivers/staging/lirc/lirc_ene0100.c deleted +0 -646

646 lines not on this page · raw message

drivers/staging/lirc/lirc_ene0100.h deleted +0 -169

169 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#12 lore raw

PATCH v2 9/9 IR: Port ene driver to new IR subsystem and enable it.

In reply to Maxim Levitsky

note that error_adjustment module option is added. This allows to reduce input samples by a percent. This makes input on my system more correct.

Default is 4% as it works best here.

Note that only normal input is adjusted. I don't know what ajustements to apply to fan tachtometer input. Maybe it is accurate already.

---
 drivers/media/IR/Kconfig  |   14 +
 drivers/media/IR/Makefile |    1 +
 drivers/media/IR/ene_ir.c |  589 +++++++++++++++++----------------------------
 drivers/media/IR/ene_ir.h |   32 +--
 4 files changed, 241 insertions(+), 395 deletions(-)
drivers/media/IR/Kconfig +14 -0
index fc48a3f..3f62bf9 100644
@@ -105,4 +105,18 @@ config IR_MCEUSB
 	   To compile this driver as a module, choose M here: the
 	   module will be called mceusb.
 
+config IR_ENE
+	tristate "ENE eHome Receiver/Transciever (pnp id: ENE0100/ENE02xxx)"
+	depends on PNP
+	depends on IR_CORE
+	---help---
+	   Say Y here to enable support for integrated infrared receiver
+	   /transciever made by ENE.
+
+	   You can see if you have it by looking at lspnp output.
+	   Output should include ENE0100 ENE0200 or something similiar.
+
+	   To compile this driver as a module, choose M here: the
+	   module will be called ene_ir.
+
 endif #IR_CORE
drivers/media/IR/Makefile +1 -0
index 2ae4f3a..3262a68 100644
@@ -16,3 +16,4 @@ obj-$(CONFIG_IR_LIRC_CODEC) += ir-lirc-codec.o
 # stand-alone IR receivers/transmitters
 obj-$(CONFIG_IR_IMON) += imon.o
 obj-$(CONFIG_IR_MCEUSB) += mceusb.o
+obj-$(CONFIG_IR_ENE) += ene_ir.o
drivers/media/IR/ene_ir.c +216 -373

857 lines not on this page · raw message

drivers/media/IR/ene_ir.h +10 -22
index 06453a8..63e5138 100644
@@ -1,5 +1,5 @@
 /*
- * driver for ENE KB3926 B/C/D CIR (also known as ENE0100/ENE0200/ENE0201)
+ * driver for ENE KB3926 B/C/D CIR (also known as ENE0XXX)
  *
  * Copyright (C) 2010 Maxim Levitsky <[email protected]>
  *
@@ -19,8 +19,7 @@
  * USA
  */
 #include <linux/spinlock.h>
-#include <media/lirc.h>
-#include <media/lirc_dev.h>
+
 
 /* hardware address */
 #define ENE_STATUS		0	/* hardware status - unused */
@@ -62,7 +61,7 @@
 /* transmitter ports */
 #define ENE_TX_PORT2		0xFC01	/* this enables one or both */
 #define ENE_TX_PORT2_EN		0x20	/* TX ports */
-#define ENE_TX_PORT1		0xFC08	
+#define ENE_TX_PORT1		0xFC08
 #define ENE_TX_PORT1_EN		0x02
 
 /* IRQ registers block (for revision B) */
@@ -88,7 +87,7 @@
 #define ENE_CIR_CONF1		0xFEC0
 #define ENE_CIR_CONF1_TX_CLEAR	0x01	/* clear that on revC */
 					/* while transmitting */
-#define ENE_CIR_CONF1_RX_ON	0x07	/* normal reciever enabled */
+#define ENE_CIR_CONF1_RX_ON	0x07	/* normal receiver enabled */
 #define ENE_CIR_CONF1_LEARN1	0x08	/* enabled on learning mode */
 #define ENE_CIR_CONF1_TX_ON	0x30	/* enabled on transmit */
 #define ENE_CIR_CONF1_TX_CARR	0x80	/* send TX carrier or not */
@@ -112,7 +111,7 @@
 /* Unknown TX setting - TX sample period ??? */
 #define ENE_TX_UNK1		0xFECB	/* set to 0x63 */
 
-/* Current recieved carrier period */
+/* Current received carrier period */
 #define ENE_RX_CARRIER		0xFECC	/* RX period (500 ns) */
 #define ENE_RX_CARRIER_VALID	0x80	/* Register content valid */
 
@@ -162,8 +161,7 @@
 
 /******************************************************************************/
 
-#define ENE_DRIVER_NAME		"enecir"
-#define ENE_TXBUF_SIZE (500 * sizeof(int))	/* 500 samples (arbitary) */
+#define ENE_DRIVER_NAME		"ene_ir"
 
 #define ENE_IRQ_RX		1
 #define ENE_IRQ_TX		2
@@ -188,7 +186,8 @@
 
 struct ene_device {
 	struct pnp_dev *pnp_dev;
-	struct lirc_driver *lirc_driver;
+	struct input_dev *idev;
+	struct ir_dev_props *props;
 	int in_use;
 
 	/* hw IO settings */
@@ -209,31 +208,20 @@ struct ene_device {
 	u8  saved_conf1;			/* saved FEC0 reg */
 	int learning_enabled;			/* learning input enabled */
 
-	/* RX sample handling */
-	int rx_sample;				/* current recieved sample */
-	int rx_sample_pulse;			/* recieved sample is pulse */
-	int rx_idle;				/* idle mode for RX activated */
-	struct timeval rx_gap_start;		/* time of start of idle */
-	int rx_timeout;				/* time in ms of RX timeout */
-	int rx_send_timeout_packet;		/* do we send RX timeout */
-	int rx_timeout_sent;			/* we sent the timeout packet */
-	int rx_carrier_sense;			/* sense carrier */
-
 	/* TX sample handling */
 	unsigned int tx_sample;			/* current sample for TX */
 	int tx_sample_pulse;			/* current sample is pulse */
 
 	/* TX buffer */
-	int tx_buffer[ENE_TXBUF_SIZE];		/* input samples buffer*/
+	int *tx_buffer;				/* input samples buffer*/
 	int tx_pos;				/* position in that bufer */
 	int tx_len;				/* current len of tx buffer */
-	int tx_underway;			/* TX is under way*/
 	int tx_done;				/* done transmitting */
 						/* one more sample pending*/
 	struct completion tx_complete;		/* TX completion */
 	struct timer_list tx_sim_timer;
 
-	/*TX settings */
+	/*settings */
 	int tx_period;
 	int tx_duty_cycle;
 	int transmitter_mask;
Signature · 1 line
1.7.0.4
Tested-by Acked-by
#13 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

In reply to Maxim Levitsky
Quoted 4 lines · Maxim Levitsky

Hi,
This is second version of the patchset. Hopefully, I didn't forget to address all comments.

Quoted 8 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Note that I send timeout report with zero value.
I don't think that this value is importaint.

I just patched the entire series into a branch here and tested, no regressions with an mceusb transceiver with in-kernel decode, lirc decode or lirc tx. Only issue I had (which I neglected to mention earlier) was some pedantic issues w/whitespace. Here's the tree I built and tested:

http://git.wilsonet.com/linux-2.6-ir-wip.git/?a=shortlog;h=refs/heads/maxim

7486d6ae3 addresses all the whitespace/formatting issues I had. Could either merge that into your patches, or I can just send it along as an additional patch after the fact. In either case, for 1-7 v2:

I have no ene hardware to actually test with, but it did build. :)

For 1-9 v2:

Signature · 2 lines
Jarod Wilson
[email protected]
#14 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 19 lines · Jarod Wilson
Quoted 4 lines · Maxim Levitsky

Hi,
This is second version of the patchset. Hopefully, I didn't forget to address all comments.

Quoted 8 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Note that I send timeout report with zero value.
I don't think that this value is importaint.

I just patched the entire series into a branch here and tested, no regressions with an mceusb transceiver with in-kernel decode, lirc decode or lirc tx. Only issue I had (which I neglected to mention earlier) was some pedantic issues w/whitespace. Here's the tree I built and tested:

Quoted 5 lines

http://git.wilsonet.com/linux-2.6-ir-wip.git/?a=shortlog;h=refs/heads/maxim

7486d6ae3 addresses all the whitespace/formatting issues I had. Could either merge that into your patches, or I can just send it along as an additional patch after the fact. In either case, for 1-7 v2:

About whitespace, I usually fix what checkpacth.pl tells me. Nothing beyond that :-)

Quoted 9 lines

I have no ene hardware to actually test with, but it did build. :)

For 1-9 v2:

Best regards,
Maxim Levitsky

#15 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 20 lines · Maxim Levitsky
Quoted 19 lines · Jarod Wilson
Quoted 4 lines · Maxim Levitsky

Hi,
This is second version of the patchset. Hopefully, I didn't forget to address all comments.

Quoted 8 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Note that I send timeout report with zero value.
I don't think that this value is importaint.

I just patched the entire series into a branch here and tested, no regressions with an mceusb transceiver with in-kernel decode, lirc decode or lirc tx. Only issue I had (which I neglected to mention earlier) was some pedantic issues w/whitespace. Here's the tree I built and tested:

Quoted 7 lines
Quoted 5 lines

http://git.wilsonet.com/linux-2.6-ir-wip.git/?a=shortlog;h=refs/heads/maxim

7486d6ae3 addresses all the whitespace/formatting issues I had. Could either merge that into your patches, or I can just send it along as an additional patch after the fact. In either case, for 1-7 v2:

About whitespace, I usually fix what checkpacth.pl tells me. Nothing beyond that :-)

Yeah, I don't think any of them violate checkpatch.pl's rules, they were more for consistency with the rest of the code being patched.

Signature · 2 lines
Jarod Wilson
[email protected]
#16 lore raw

Re: <kein Betreff>

In reply to Maxim Levitsky

Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]

Quoted 8 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

#17 lore raw

v2 cover IR: few fixes, additions and ENE driver

Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]

Quoted 6 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Quoted 7 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

Could you explain exactly how timeout reports work?

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

Best regards,
Maxim Levitsky

#18 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 21 lines · Maxim Levitsky
Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]

Quoted 6 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Quoted 7 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

Could you explain exactly how timeout reports work?

Quoted 8 lines

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

Best regards,
Maxim Levitsky

Just for some context, the Conexant hardware generates such reports on it's hardware Rx FIFO:

Quoted 1 line

From section 3.8.2.3 of

http://dl.ivtvdriver.org/datasheets/video/cx25840.pdf

"When the demodulated input signal no longer transitions, the RX pulse width timer overflows, which indicates the end of data transmission. When this occurs, the timer value contains all 1s. This value can be stored to the RX FIFO, to indicate the end of the transmission [...]. Additionally, a status bit is set which can interrupt the microprocessor, [...]".

So the value in the hardware RX FIFO is the maximum time measurable given the current hardware clock divider settings, plus a flag bit indicating overflow.

The CX2388[58] IR implementation currently translates that hardware notification into V4L2_SUBDEV_IR_PULSE_RX_SEQ_END:

http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=drivers/media/video/cx23885/cx23888-ir.c;h=51f21636e639330bcf528568c0f08c7a4a674f42;hb=094fc94360cf01960da3311698fedfca566d4712#l678

which is defined here:

http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=include/media/v4l2-subdev.h;h=bacd52568ef9fd17787554aa347f46ca6f23bdb2;hb=094fc94360cf01960da3311698fedfca566d4712#l366

as

#define V4L2_SUBDEV_IR_PULSE_RX_SEQ_END 0xffffffff

I didn't look too hard at it, but IIRC the in kernel decoders would have interpreted this value incorrectly (the longest possible mark). Instead, I just pass along the longest possible space:

http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=drivers/media/video/cx23885/cx23885-input.c;h=3f924e21b9575f7d67d99d71c8585d41828aabfe;hb=094fc94360cf01960da3311698fedfca566d4712#l49

so it acts as in band signaling if anyone is looking for it, and the in kernel decoders happily treat it like a long space.

With a little work, I could pass the actual time it took for the Rx timer to timeout as well (Provide the space measurement *and* the in band signal), if needed.

Regards,
Andy

#19 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 22 lines · Andy Walls
Quoted 21 lines · Maxim Levitsky
Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]

Quoted 6 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Quoted 7 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

Could you explain exactly how timeout reports work?

Quoted 8 lines
Quoted 8 lines

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

Best regards,
Maxim Levitsky

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

Christoph, right?

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

I think this is the best solution.

Best regards,
Maxim Levitsky

#20 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 29 lines · Maxim Levitsky
Quoted 28 lines · Andy Walls
Quoted 27 lines · Maxim Levitsky
Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]

Quoted 6 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Quoted 7 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

Could you explain exactly how timeout reports work?

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Best regards,
Maxim Levitsky

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

On a measurement timeout, the Conexant hardware RX FIFO has this special timer overflow value in it as the last measurement:

	value = 0x1ffff => a mark with a measurement of 65535 * 4 clocks

(and the measurement before this one in the FIFO is usually the last actual mark received).

I ultimately translate that to

	pulse = false;		/* a space */
	duration = 0x7fffffff;  /* 2.147 seconds */

to give the in kernel decoders a final space.

What is lost is the actual space measurement by the hardware (whatever 65535 * 4 Rx clocks is), before the timeout.

If LIRC likes to measure intertransmission gaps, what I am currently doing will not give LIRC a reasonable gap estimate/measurement, if the timeout is shorter than the actual gap.

Quoted 8 lines

Christoph, right?

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

I think this is the best solution.

I'm flexible. I don't know LIRC internals well enough to know what's best. I suspect sending a valid space measurement of the timeout, before the timeout report, may be useful for LIRC to obtain information on the gaps that are longer than the hardware timeout.

Regards,
Andy

Quoted 3 lines

Best regards,
Maxim Levitsky

#21 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

In reply to Maxim Levitsky

Hi Maxim,

Quoted 29 lines · Maxim Levitsky
Quoted 28 lines · Andy Walls
Quoted 27 lines · Maxim Levitsky
Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]

Quoted 6 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached. This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Quoted 7 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

Could you explain exactly how timeout reports work?

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Best regards,
Maxim Levitsky

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

No, a timeout report is just an additional hint for the decoder that a specific amount of time has passed since the last pulse _now_.

[...]

Quoted 4 lines

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

When timeout reports are enabled the sequence must be:
<pulse> <timeout> <space> <pulse>
where <timeout> is optional.

lircd will not work when you leave out the space. It must know the exact time between the pulses. Some hardware generates timeout reports that are too short to distinguish between spaces that are so short that the next sequence can be interpreted as a repeat or longer spaces which indicate that this is a new key press.

Christoph

#22 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 51 lines · Christoph Bartelmus

Hi Maxim,

Quoted 29 lines · Maxim Levitsky
Quoted 28 lines · Andy Walls
Quoted 27 lines · Maxim Levitsky
Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]

Quoted 6 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached. This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Quoted 7 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

Could you explain exactly how timeout reports work?

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Best regards,
Maxim Levitsky

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

No, a timeout report is just an additional hint for the decoder that a specific amount of time has passed since the last pulse _now_.

[...]

Quoted 4 lines

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

When timeout reports are enabled the sequence must be:
<pulse> <timeout> <space> <pulse>
where <timeout> is optional.

Quoted 5 lines

lircd will not work when you leave out the space. It must know the exact time between the pulses. Some hardware generates timeout reports that are too short to distinguish between spaces that are so short that the next sequence can be interpreted as a repeat or longer spaces which indicate that this is a new key press.

Let me give an example to see if I got that right.

Suppose we have this sequence of reports from the driver:

500 (pulse)
200000 (timeout)
100000000 (space)
500 (pulse)

Is that correct that time between first and second pulse is '100200000' ?

Best regards,
Maxim Levitsky

#23 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Hi!

Maxim Levitsky "[email protected]" wrote:
[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Could you explain exactly how timeout reports work?

[...]

Quoted 27 lines
Quoted 16 lines
Quoted 2 lines

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

No, a timeout report is just an additional hint for the decoder that a specific amount of time has passed since the last pulse _now_.

[...]

Quoted 4 lines

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

When timeout reports are enabled the sequence must be:
<pulse> <timeout> <space> <pulse>
where <timeout> is optional.

Quoted 5 lines

lircd will not work when you leave out the space. It must know the exact time between the pulses. Some hardware generates timeout reports that are too short to distinguish between spaces that are so short that the next sequence can be interpreted as a repeat or longer spaces which indicate that this is a new key press.

Let me give an example to see if I got that right.

Suppose we have this sequence of reports from the driver:

Quoted 8 lines

500 (pulse)
200000 (timeout)
100000000 (space)
500 (pulse)

Is that correct that time between first and second pulse is '100200000' ?

No, it's 100000000. The timeout is optional and just a hint to the decoder how much time has passed already since the last pulse. It does not change the meaning of the next space.

Christoph

#24 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 39 lines · Christoph Bartelmus

Hi!

Maxim Levitsky "[email protected]" wrote:
[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Could you explain exactly how timeout reports work?

[...]

Quoted 33 lines
Quoted 16 lines
Quoted 2 lines

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

No, a timeout report is just an additional hint for the decoder that a specific amount of time has passed since the last pulse _now_.

[...]

Quoted 4 lines

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

When timeout reports are enabled the sequence must be:
<pulse> <timeout> <space> <pulse>
where <timeout> is optional.

Quoted 5 lines

lircd will not work when you leave out the space. It must know the exact time between the pulses. Some hardware generates timeout reports that are too short to distinguish between spaces that are so short that the next sequence can be interpreted as a repeat or longer spaces which indicate that this is a new key press.

Let me give an example to see if I got that right.

Suppose we have this sequence of reports from the driver:

500 (pulse)
200000 (timeout)
100000000 (space)
500 (pulse)

Quoted 6 lines
Quoted 2 lines

Is that correct that time between first and second pulse is '100200000' ?

No, it's 100000000. The timeout is optional and just a hint to the decoder how much time has passed already since the last pulse. It does not change the meaning of the next space.

its like a carrier report then I guess.
Its clear to me now.

So, I really don't need to send/support timeout reports because hw doesn't support that.

I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to adjust threshold upon which I stop the hardware, and remember current time.
I can put that in generic function for ene like hardware (hw that sends small packs of samples very often)

Best regards,
Maxim Levitsky

#25 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 50 lines · Maxim Levitsky
Quoted 39 lines · Christoph Bartelmus

Hi!

Maxim Levitsky "[email protected]" wrote:
[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Could you explain exactly how timeout reports work?

[...]

Quoted 33 lines
Quoted 16 lines
Quoted 2 lines

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

No, a timeout report is just an additional hint for the decoder that a specific amount of time has passed since the last pulse _now_.

[...]

Quoted 4 lines

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

When timeout reports are enabled the sequence must be:
<pulse> <timeout> <space> <pulse>
where <timeout> is optional.

Quoted 5 lines

lircd will not work when you leave out the space. It must know the exact time between the pulses. Some hardware generates timeout reports that are too short to distinguish between spaces that are so short that the next sequence can be interpreted as a repeat or longer spaces which indicate that this is a new key press.

Let me give an example to see if I got that right.

Suppose we have this sequence of reports from the driver:

500 (pulse)
200000 (timeout)
100000000 (space)
500 (pulse)

Quoted 6 lines
Quoted 2 lines

Is that correct that time between first and second pulse is '100200000' ?

No, it's 100000000. The timeout is optional and just a hint to the decoder how much time has passed already since the last pulse. It does not change the meaning of the next space.

its like a carrier report then I guess.
Its clear to me now.

Quoted 8 lines

So, I really don't need to send/support timeout reports because hw doesn't support that.

I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to adjust threshold upon which I stop the hardware, and remember current time.
I can put that in generic function for ene like hardware (hw that sends small packs of samples very often)

So... I presume this means a v3 patchset? And/or, is it worth merging patches 1, 2, 3, 6 and 7 now, then having you work on top of that?

Signature · 2 lines
Jarod Wilson
[email protected]
#26 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 54 lines · Jarod Wilson
Quoted 53 lines · Maxim Levitsky
Quoted 39 lines · Christoph Bartelmus

Hi!

Maxim Levitsky "[email protected]" wrote:
[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Could you explain exactly how timeout reports work?

[...]

Quoted 33 lines
Quoted 16 lines
Quoted 2 lines

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

No, a timeout report is just an additional hint for the decoder that a specific amount of time has passed since the last pulse _now_.

[...]

Quoted 4 lines

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

When timeout reports are enabled the sequence must be:
<pulse> <timeout> <space> <pulse>
where <timeout> is optional.

Quoted 5 lines

lircd will not work when you leave out the space. It must know the exact time between the pulses. Some hardware generates timeout reports that are too short to distinguish between spaces that are so short that the next sequence can be interpreted as a repeat or longer spaces which indicate that this is a new key press.

Let me give an example to see if I got that right.

Suppose we have this sequence of reports from the driver:

500 (pulse)
200000 (timeout)
100000000 (space)
500 (pulse)

Quoted 6 lines
Quoted 2 lines

Is that correct that time between first and second pulse is '100200000' ?

No, it's 100000000. The timeout is optional and just a hint to the decoder how much time has passed already since the last pulse. It does not change the meaning of the next space.

its like a carrier report then I guess.
Its clear to me now.

So, I really don't need to send/support timeout reports because hw doesn't support that.

Quoted 8 lines
Quoted 5 lines

I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to adjust threshold upon which I stop the hardware, and remember current time.
I can put that in generic function for ene like hardware (hw that sends small packs of samples very often)

So... I presume this means a v3 patchset? And/or, is it worth merging patches 1, 2, 3, 6 and 7 now, then having you work on top of that?

This branch is a as-of-a-few-minutes-ago, up-to-date linuxtv staging/other plus a few outstanding patches and your patches 1, 2, 3, 6 and 7:

http://git.wilsonet.com/linux-2.6-ir-wip.git/?a=shortlog;h=refs/heads/staging

Signature · 2 lines
Jarod Wilson
[email protected]
#27 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 61 lines · Jarod Wilson
Quoted 60 lines · Jarod Wilson
Quoted 58 lines · Maxim Levitsky
Quoted 39 lines · Christoph Bartelmus

Hi!

Maxim Levitsky "[email protected]" wrote:
[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Could you explain exactly how timeout reports work?

[...]

Quoted 33 lines
Quoted 16 lines
Quoted 2 lines

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

No, a timeout report is just an additional hint for the decoder that a specific amount of time has passed since the last pulse _now_.

[...]

Quoted 4 lines

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

When timeout reports are enabled the sequence must be:
<pulse> <timeout> <space> <pulse>
where <timeout> is optional.

Quoted 5 lines

lircd will not work when you leave out the space. It must know the exact time between the pulses. Some hardware generates timeout reports that are too short to distinguish between spaces that are so short that the next sequence can be interpreted as a repeat or longer spaces which indicate that this is a new key press.

Let me give an example to see if I got that right.

Suppose we have this sequence of reports from the driver:

500 (pulse)
200000 (timeout)
100000000 (space)
500 (pulse)

Quoted 6 lines
Quoted 2 lines

Is that correct that time between first and second pulse is '100200000' ?

No, it's 100000000. The timeout is optional and just a hint to the decoder how much time has passed already since the last pulse. It does not change the meaning of the next space.

its like a carrier report then I guess.
Its clear to me now.

So, I really don't need to send/support timeout reports because hw doesn't support that.

I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to adjust threshold upon which I stop the hardware, and remember current time.
I can put that in generic function for ene like hardware (hw that sends small packs of samples very often)

Quoted 6 lines
Quoted 2 lines

So... I presume this means a v3 patchset? And/or, is it worth merging patches 1, 2, 3, 6 and 7 now, then having you work on top of that?

This branch is a as-of-a-few-minutes-ago, up-to-date linuxtv staging/other plus a few outstanding patches and your patches 1, 2, 3, 6 and 7:

I am surely send V3 and likely V4.
I changed many of my patches,

I now am chasing a very strange leak of samples I see. (sometimes, randomaly a sample goes missing, and that breaks in-kernel decoding...) It appears to be not my driver fault, nor fifo overflow...

Best regards,
Maxim Levitsky

#28 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 69 lines · Maxim Levitsky
Quoted 61 lines · Jarod Wilson
Quoted 60 lines · Jarod Wilson
Quoted 58 lines · Maxim Levitsky
Quoted 39 lines · Christoph Bartelmus

Hi!

Maxim Levitsky "[email protected]" wrote:
[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Could you explain exactly how timeout reports work?

[...]

Quoted 33 lines
Quoted 16 lines
Quoted 2 lines

So, timeout report is just another sample, with a mark attached, that this is last sample? right?

No, a timeout report is just an additional hint for the decoder that a specific amount of time has passed since the last pulse _now_.

[...]

Quoted 4 lines

In that case, lets do that this way:

As soon as timeout is reached, I just send lirc the timeout report. Then next keypress will start with pulse.

When timeout reports are enabled the sequence must be:
<pulse> <timeout> <space> <pulse>
where <timeout> is optional.

Quoted 5 lines

lircd will not work when you leave out the space. It must know the exact time between the pulses. Some hardware generates timeout reports that are too short to distinguish between spaces that are so short that the next sequence can be interpreted as a repeat or longer spaces which indicate that this is a new key press.

Let me give an example to see if I got that right.

Suppose we have this sequence of reports from the driver:

500 (pulse)
200000 (timeout)
100000000 (space)
500 (pulse)

Quoted 6 lines
Quoted 2 lines

Is that correct that time between first and second pulse is '100200000' ?

No, it's 100000000. The timeout is optional and just a hint to the decoder how much time has passed already since the last pulse. It does not change the meaning of the next space.

its like a carrier report then I guess.
Its clear to me now.

So, I really don't need to send/support timeout reports because hw doesn't support that.

I can however support timeout (LIRC_SET_REC_TIMEOUT) and and use it to adjust threshold upon which I stop the hardware, and remember current time.
I can put that in generic function for ene like hardware (hw that sends small packs of samples very often)

Quoted 6 lines
Quoted 2 lines

So... I presume this means a v3 patchset? And/or, is it worth merging patches 1, 2, 3, 6 and 7 now, then having you work on top of that?

This branch is a as-of-a-few-minutes-ago, up-to-date linuxtv staging/other plus a few outstanding patches and your patches 1, 2, 3, 6 and 7:

Quoted 6 lines

I am surely send V3 and likely V4.
I changed many of my patches,

I now am chasing a very strange leak of samples I see. (sometimes, randomaly a sample goes missing, and that breaks in-kernel decoding...) It appears to be not my driver fault, nor fifo overflow...

Rolls eyes....

void ir_raw_event_handle(struct input_dev *input_dev) {
struct ir_input_dev *ir = input_get_drvdata(input_dev);

if (!ir->raw)
return;

schedule_work(&ir->raw->rx_work);
}
EXPORT_SYMBOL_GPL(ir_raw_event_handle);

This is workqueue, so who said two of them can run at same time.....

Best regards,
Maxim Levitsky

#29 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

In reply to Christoph Bartelmus
Quoted 4 lines · Christoph Bartelmus
Quoted 3 lines · Maxim Levitsky
Quoted 2 lines · Andy Walls
Quoted 1 line · Maxim Levitsky

On Thu, 2010-07-29 at 09:23 +0200, Christoph Bartelmus wrote:

Hi Christoph, Mauro, and Jarrod

Quoted 3 lines

When timeout reports are enabled the sequence must be:
<pulse> <timeout> <space> <pulse>
where <timeout> is optional.

OK. This is some of the detail I needed.

I'm looking at the master branch of Jarrod's wip git repo, but:

1. I don't see how a timeout report is going to make it through

drivers/media/IR/ir-lirc-codec.c:lir_lirc_decode()

I guess I'll have to add a "flags" field (or something) to

include/media/ir_core.h:struct ir_raw_event

to modify the events beyond just mark or space reports.

Mauro, do you have any preferences or comments here?

2. The in-kernel decoders normally need a the final space to close out the decoding, so the above sequence will cause them to wait. It would only really be noticiable if no repeat came from the remote, but it still would be annoying.

If I send a space for the timeout to get the in kernel decoders to close out decoding, then I end up sending a double space out to LIRC, which I just read will confuse LIRC.

So...

If I'm going to add a timeout event flag to struct ir_raw_event, I suppose we could either:

a. have the current in kernel decoders interpret an
ir_raw_event with a timeout event as a cue to conclude decoding the current pulse train

b. add a "finish decode" flag and have the in kernel decoders
respond to that.

I beleive this will also let the in-kernel decoders still respond to final space as they currently do.

Objections? comments?

3. When my hardware times out, it stops measuring anything, until it sees a new edge. For short timeout settings (smaller than the intertransmission gap), I will have generate a space in software to provide the length of the gap.

I'll have to store the time of reading the timeout flag of the hardware Rx FIFO, compute an approximate gap length when the next mark measurement comes in, and insert a the space. The gaps space time will only be approximate, as the Rx FIFO watermark is set to interrupt at 4 measurements in the FIFO.

If I can't do #1 & #2 above, I'm not sure how I can send any in band signaling out to user space.

Regards,
Andy

Quoted 7 lines

lircd will not work when you leave out the space. It must know the exact time between the pulses. Some hardware generates timeout reports that are too short to distinguish between spaces that are so short that the next sequence can be interpreted as a repeat or longer spaces which indicate that this is a new key press.

Christoph

#30 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

In reply to Andy Walls

Hi Andy,

Quoted 75 lines · Andy Walls
Quoted 21 lines · Maxim Levitsky
Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 02:40, Maxim Levitsky wrote:
[...]

Quoted 6 lines

In addition to comments, I changed helper function that processes samples so it sends last space as soon as timeout is reached.
This breaks somewhat lirc, because now it gets 2 spaces in row. However, if it uses timeout reports (which are now fully supported) it will get such report in middle.

Quoted 7 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

Could you explain exactly how timeout reports work?

Quoted 8 lines

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

Best regards,
Maxim Levitsky

Just for some context, the Conexant hardware generates such reports on it's hardware Rx FIFO:

Quoted 1 line

From section 3.8.2.3 of

http://dl.ivtvdriver.org/datasheets/video/cx25840.pdf

"When the demodulated input signal no longer transitions, the RX pulse width timer overflows, which indicates the end of data transmission. When this occurs, the timer value contains all 1s. This value can be stored to the RX FIFO, to indicate the end of the transmission [...]. Additionally, a status bit is set which can interrupt the microprocessor, [...]".

So the value in the hardware RX FIFO is the maximum time measurable given the current hardware clock divider settings, plus a flag bit indicating overflow.

The CX2388[58] IR implementation currently translates that hardware notification into V4L2_SUBDEV_IR_PULSE_RX_SEQ_END:

http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=drivers/media/video/cx238
85/cx23888-ir.c;h=51f21636e639330bcf528568c0f08c7a4a674f42;hb=094fc94360cf01 960da3311698fedfca566d4712#l678

which is defined here:

http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=include/media/v4l2-subdev
.h;h=bacd52568ef9fd17787554aa347f46ca6f23bdb2;hb=094fc94360cf01960da3311698f edfca566d4712#l366

as

#define V4L2_SUBDEV_IR_PULSE_RX_SEQ_END 0xffffffff

I didn't look too hard at it, but IIRC the in kernel decoders would have interpreted this value incorrectly (the longest possible mark). Instead, I just pass along the longest possible space:

http://git.linuxtv.org/awalls/v4l-dvb.git?a=blob;f=drivers/media/video/cx238
85/cx23885-input.c;h=3f924e21b9575f7d67d99d71c8585d41828aabfe;hb=094fc94360c f01960da3311698fedfca566d4712#l49

Quoted 6 lines

so it acts as in band signaling if anyone is looking for it, and the in kernel decoders happily treat it like a long space.

With a little work, I could pass the actual time it took for the Rx timer to timeout as well (Provide the space measurement *and* the in band signal), if needed.

The value for LIRC_MODE2_TIMEOUT needs to be the exact value of the acutal time passed since the last pulse. When you just send the longest possible space instead, you'll make repeat detection impossible.

Christoph

#31 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

In reply to Maxim Levitsky

Hi Maxim,

on 29 Jul 10 at 17:41, Maxim Levitsky wrote:
[...]

Quoted 9 lines
Quoted 7 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

Could you explain exactly how timeout reports work?

It all should be documented in the interface description. Jarod probably can point you where it can be found.
Timeout reports can only be generated by the hardware because only the hardware can know the exact amount of time passed since the last pulse when any kind of buffering is used by the hardware. You see this esp. with USB devices.

Quoted 5 lines

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

For sure I will not agree to any constant introduced here. And I also don't see why. Can you explain why you are trying to change the lirc interface here?

Christoph

#32 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 12 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 17:41, Maxim Levitsky wrote:
[...]

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Christoph

Quoted 8 lines
Quoted 1 line

Could you explain exactly how timeout reports work?

It all should be documented in the interface description. Jarod probably can point you where it can be found.
Timeout reports can only be generated by the hardware because only the hardware can know the exact amount of time passed since the last pulse when any kind of buffering is used by the hardware. You see this esp. with USB devices.

In my case hardware doesn't have that capability.
However, I though that timeout reports are useful to stop hardware as soon at timeout it hit.

Quoted 10 lines
Quoted 6 lines

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

For sure I will not agree to any constant introduced here. And I also don't see why. Can you explain why you are trying to change the lirc interface here?

Currently, to comply with strict lirc requirements I have to send one big space between keypresses. Of course I can send it only when I get next pulse, which might happen much later.

However, the in-kernel decoders depend on the last space to be sent right away.
that it I need to and a keypress with a space, but currently it ends with pulse.

So my idea was to wait reasonable time for next pulse, and if it doesn't arrive, send a space mark even though no new pulse is registered.

Of course the size of that space can be configured.

Best regards,
Maxim Levitsky

#33 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Hi!

Quoted 19 lines · Maxim Levitsky "[email protected]" wrote:
Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 17:41, Maxim Levitsky wrote:
[...]

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Quoted 8 lines
Quoted 1 line

Could you explain exactly how timeout reports work?

It all should be documented in the interface description. Jarod probably can point you where it can be found.
Timeout reports can only be generated by the hardware because only the hardware can know the exact amount of time passed since the last pulse when any kind of buffering is used by the hardware. You see this esp. with USB devices.

Quoted 3 lines

In my case hardware doesn't have that capability.
However, I thought that timeout reports are useful to stop hardware as soon as timeout is hit.

You are starting a software timer for this? That's not the intention of timeout reports. It's just a hint to the decoder which needs to run it's own timer anyway. Having to stop the hardware is something very specific to your driver.

Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

For sure I will not agree to any constant introduced here. And I also don't see why. Can you explain why you are trying to change the lirc interface here?

Quoted 6 lines

Currently, to comply with strict lirc requirements I have to send one big space between keypresses. Of course I can send it only when I get next pulse, which might happen much later.

However, the in-kernel decoders depend on the last space to be sent right away.

Ugh. What's the most polite way to express my disgust? ;)

Quoted 7 lines

that it I need to and a keypress with a space, but currently it ends with pulse.

So my idea was to wait reasonable time for next pulse, and if it doesn't arrive, send a space mark even though no new pulse is registered.

Of course the size of that space can be configured.

The "reasonable time" is protocol specific and must be handled by the decoder IMHO and not by the driver.

Christoph

#34 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

Quoted 42 lines · Christoph Bartelmus

Hi!

Quoted 19 lines · Maxim Levitsky "[email protected]" wrote:
Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 17:41, Maxim Levitsky wrote:
[...]

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Quoted 8 lines
Quoted 1 line

Could you explain exactly how timeout reports work?

It all should be documented in the interface description. Jarod probably can point you where it can be found.
Timeout reports can only be generated by the hardware because only the hardware can know the exact amount of time passed since the last pulse when any kind of buffering is used by the hardware. You see this esp. with USB devices.

Quoted 3 lines

In my case hardware doesn't have that capability.
However, I thought that timeout reports are useful to stop hardware as soon as timeout is hit.

You are starting a software timer for this? That's not the intention of timeout reports. It's just a hint to the decoder which needs to run it's own timer anyway. Having to stop the hardware is something very specific to your driver.

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

Lirc interface isn't set to stone, so how about a reasonable compromise. After reasonable long period of inactivity (200 ms for example), space is sent, and then next report starts with a pulse.
So gaps between keypresses will be maximum of 200 ms, and as a bonus I could rip of the logic that deals with remembering the time?

For sure I will not agree to any constant introduced here. And I also don't see why. Can you explain why you are trying to change the lirc interface here?

Quoted 8 lines
Quoted 6 lines

Currently, to comply with strict lirc requirements I have to send one big space between keypresses. Of course I can send it only when I get next pulse, which might happen much later.

However, the in-kernel decoders depend on the last space to be sent right away.

Ugh. What's the most polite way to express my disgust? ;)

That what I think lately about that too.
A space is really a space. After which a pulse is received. Therefore, lets just remove that cruft from in-kernel decoders? Anyway, even a 200 ms is still time. Its useless to add unnecessary latency to input.

Quoted 11 lines
Quoted 8 lines

that it I need to and a keypress with a space, but currently it ends with pulse.

So my idea was to wait reasonable time for next pulse, and if it doesn't arrive, send a space mark even though no new pulse is registered.

Of course the size of that space can be configured.

The "reasonable time" is protocol specific and must be handled by the decoder IMHO and not by the driver.

It can't do that. Due to requirement of alternation between pulses and spaces, decoder doesn't see a hide nor hair of the last space, even though internally it keeps growing because hardware continues to send spaces.

I am now confident that its just a decoder fault, and must be fixed.

Best regards,
Maxim Levitsky

#35 lore raw

Re: [PATCH 0/9 v2] IR: few fixes, additions and ENE driver

In reply to Christoph Bartelmus
Quoted 10 lines · Christoph Bartelmus

Hi Maxim,

on 29 Jul 10 at 17:41, Maxim Levitsky wrote:
[...]

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Note that I send timeout report with zero value.
I don't think that this value is importaint.

This does not sound good. Of course the value is important to userspace and 2 spaces in a row will break decoding.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Christoph

Could you explain exactly how timeout reports work?

It all should be documented in the interface description. Jarod probably can point you where it can be found.

There's a start to interface documentation at Documentation/DocBook/v4l/lirc_device_interface.xml, and it does cover timeout report usage.

(Side note: I forgot, Mauro asked if we could flesh out that document even further with descriptions of the assorted defines beyond just the ioctls. I'm going to scribble that on my TODO list right now...)

Signature · 2 lines
Jarod Wilson
[email protected]