Re: [PATCH 6/7] IR: extend ir_raw_event and do refactoring

2010-09-02 Thread David Härdeman
On Fri, Sep 03, 2010 at 12:20:54AM +0300, Maxim Levitsky wrote:
> Also in the future I think I should make the
> ir_raw_event_store_with_filter the default submit function for all
> drivers, and then I could drop that silly '_with_filter" thing
> (Couldn't think for a better name for this function...)

I agree. Perhaps it would even be possible to merge 
ir_raw_event_store_with_filter and ir_raw_event_store. The automatic 
merger of consecutive pulse-pulse events or space-space events should 
help simplify some drivers...

> > Wouldn't DEFINE_RAW_EVENT(ev); be more in line with the kernel 
> > coding style? (cf. DEFINE_MUTEX, DEFINE_SPINLOCK, etc).
> Of course, nothing against that.

DEFINE_RC_RAW_EVENT() is probably better by the way...

-- 
David Härdeman
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/7] IR: extend ir_raw_event and do refactoring

2010-09-02 Thread Maxim Levitsky
On Thu, 2010-09-02 at 22:56 +0200, David Härdeman wrote: 
> On Mon, Aug 30, 2010 at 11:52:26AM +0300, Maxim Levitsky wrote:
> > Add new event types for timeout & carrier report
> > Move timeout handling from ir_raw_event_store_with_filter to
> > ir-lirc-codec, where it is really needed.
> 
> Yes, but it still might make more sense to keep the timeout handling in 
> ir_raw_event_store_with_filter so that all decoders get the same data 
> from rc-core?
I don't want any timeouts in rc-core. There is just an IR packet that
starts optionally with a reset and ends with a timeout bit.
I have also nothing against renaming reset/timeout to start/stop.

rc-core really shouldn't care about consistent pulse/space ordering.
Its lirc that needs it.

Also in the future I think I should make the
ir_raw_event_store_with_filter the default submit function for all
drivers, and then I could drop that silly '_with_filter" thing
(Couldn't think for a better name for this function...)

> 
> > Now lirc bridge ensures proper gap handling.
> > Extend lirc bridge for carrier & timeout reports
> > 
> > Note: all new ir_raw_event variables now should be initialized
> > like that:
> > struct ir_raw_event ev = ir_new_event;
> 
> Wouldn't DEFINE_RAW_EVENT(ev); be more in line with the kernel coding 
> style? (cf. DEFINE_MUTEX, DEFINE_SPINLOCK, etc).
Of course, nothing against that.


Best regards,
Maxim Levitsky

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/7] IR: extend ir_raw_event and do refactoring

2010-09-02 Thread David Härdeman
On Mon, Aug 30, 2010 at 11:52:26AM +0300, Maxim Levitsky wrote:
> Add new event types for timeout & carrier report
> Move timeout handling from ir_raw_event_store_with_filter to
> ir-lirc-codec, where it is really needed.

Yes, but it still might make more sense to keep the timeout handling in 
ir_raw_event_store_with_filter so that all decoders get the same data 
from rc-core?

> Now lirc bridge ensures proper gap handling.
> Extend lirc bridge for carrier & timeout reports
> 
> Note: all new ir_raw_event variables now should be initialized
> like that:
> struct ir_raw_event ev = ir_new_event;

Wouldn't DEFINE_RAW_EVENT(ev); be more in line with the kernel coding 
style? (cf. DEFINE_MUTEX, DEFINE_SPINLOCK, etc).

-- 
David Härdeman
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] IR: extend ir_raw_event and do refactoring

2010-08-30 Thread Maxim Levitsky
Add new event types for timeout & carrier report
Move timeout handling from ir_raw_event_store_with_filter to
ir-lirc-codec, where it is really needed.
Now lirc bridge ensures proper gap handling.
Extend lirc bridge for carrier & timeout reports

Note: all new ir_raw_event variables now should be initialized
like that:
struct ir_raw_event ev = ir_new_event;

Signed-off-by: Maxim Levitsky 
---
 drivers/media/IR/ene_ir.c  |2 +-
 drivers/media/IR/ene_ir.h  |2 +-
 drivers/media/IR/ir-core-priv.h|   11 +-
 drivers/media/IR/ir-jvc-decoder.c  |5 ++-
 drivers/media/IR/ir-lirc-codec.c   |   66 
 drivers/media/IR/ir-nec-decoder.c  |5 ++-
 drivers/media/IR/ir-raw-event.c|   41 +-
 drivers/media/IR/ir-rc5-decoder.c  |5 ++-
 drivers/media/IR/ir-rc6-decoder.c  |5 ++-
 drivers/media/IR/ir-sony-decoder.c |5 ++-
 drivers/media/IR/mceusb.c  |2 +-
 drivers/media/IR/streamzap.c   |6 ++--
 include/media/ir-core.h|   26 --
 13 files changed, 121 insertions(+), 60 deletions(-)

diff --git a/drivers/media/IR/ene_ir.c b/drivers/media/IR/ene_ir.c
index 8e3e0c8..c7bbbca 100644
--- a/drivers/media/IR/ene_ir.c
+++ b/drivers/media/IR/ene_ir.c
@@ -699,7 +699,7 @@ static irqreturn_t ene_isr(int irq, void *data)
unsigned long flags;
irqreturn_t retval = IRQ_NONE;
struct ene_device *dev = (struct ene_device *)data;
-   struct ir_raw_event ev;
+   struct ir_raw_event ev = ir_new_event;
 
spin_lock_irqsave(&dev->hw_lock, flags);
 
diff --git a/drivers/media/IR/ene_ir.h b/drivers/media/IR/ene_ir.h
index 69a0ae0..27b2eb0 100644
--- a/drivers/media/IR/ene_ir.h
+++ b/drivers/media/IR/ene_ir.h
@@ -188,7 +188,7 @@
  *  And there is nothing to change this setting
  */
 
-#define ENE_MAXGAP (0xFFF * 0x61)
+#define ENE_MAXGAP 2
 #define ENE_MINGAP (127 * sample_period)
 
 
/**/
diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index 5d7e08f..a287373 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -82,6 +82,10 @@ struct ir_raw_event_ctrl {
struct ir_input_dev *ir_dev;
struct lirc_driver *drv;
int carrier_low;
+   ktime_t timeout_start;
+   bool timeout;
+   bool send_timeout_reports;
+
} lirc;
 };
 
@@ -109,9 +113,14 @@ static inline void decrease_duration(struct ir_raw_event 
*ev, unsigned duration)
ev->duration -= duration;
 }
 
+/* Returns true if event is normal pulse/space event */
+static inline bool is_timing_event(struct ir_raw_event ev)
+{
+   return !ev.carrier_report && !ev.reset;
+}
+
 #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
diff --git a/drivers/media/IR/ir-jvc-decoder.c 
b/drivers/media/IR/ir-jvc-decoder.c
index 77a89c4..63dca6e 100644
--- a/drivers/media/IR/ir-jvc-decoder.c
+++ b/drivers/media/IR/ir-jvc-decoder.c
@@ -50,8 +50,9 @@ static int ir_jvc_decode(struct input_dev *input_dev, struct 
ir_raw_event ev)
if (!(ir_dev->raw->enabled_protocols & IR_TYPE_JVC))
return 0;
 
-   if (IS_RESET(ev)) {
-   data->state = STATE_INACTIVE;
+   if (!is_timing_event(ev)) {
+   if (ev.reset)
+   data->state = STATE_INACTIVE;
return 0;
}
 
diff --git a/drivers/media/IR/ir-lirc-codec.c b/drivers/media/IR/ir-lirc-codec.c
index e63f757..e6ca7a3 100644
--- a/drivers/media/IR/ir-lirc-codec.c
+++ b/drivers/media/IR/ir-lirc-codec.c
@@ -32,7 +32,9 @@
 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);
+   struct lirc_codec *lirc = &ir_dev->raw->lirc;
int sample;
+   int duration_msec;
 
if (!(ir_dev->raw->enabled_protocols & IR_TYPE_LIRC))
return 0;
@@ -40,21 +42,56 @@ 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))
+   duration_msec = DIV_ROUND_CLOSEST(ev.duration, 1000);
+
+   if (ev.reset)
return 0;
 
-   IR_dprintk(2, "LIRC data transfer started (%uus %s)\n",
-  TO_US(ev.duration), TO_STR(ev.pulse));
+   if (ev.carrier_report) {
+   /* TODO: send RX duty cycle */
+   sample = LIRC_FREQUENCY(ev.carrier);
+
+   } else if (ev.timeout) {
+