Control Framework Roadmap

2010-04-08 Thread Hans Verkuil
OK, the discussion in response to my RFC was very enlightening. Based on
that I decided on the following roadmap:

1) Remove the sysfs code from the framework for the time being.

It is not necessary for the first version. What I would like to do is to take
another good look at the data structures and code to see if I can organize it
in such a way that adding debugfs and/or sysfs in the future would be very
easy to do. I also want to make sure that 'remap' functionality would be
easy to add later. I strongly suspect that we will need that for certain
corner cases as Andy described.

2) Verify that uvc can work with this.

The UVC driver can dynamically add new controls for UVC webcams. It should
work with the framework but this needs to be verified. This will take some
time since both Laurent and myself are busy for the next two weeks.

3) If all is OK, then I can post a patch series for the basic framework.

4) Once merged the work can begin on converting bridge and subdev drivers.

5) Further discuss sysfs/debugfs support.

Support for sysfs (and possibly debugfs) will depend on the event patches
being merged (as that introduces struct v4l2_fh) and the proposed pre/post
hooks in ioctl_ops. Pre/post hooks in turn depend on improve core support for
v4l2_priority (which in turn depends on the struct v4l2_fh). It's all pretty
trivial code, but it is needed to provide a 'fixed' control path that drivers
can rely on. No matter whether the driver is approached via an ioctl, sysfs
or debugfs, from the point of view of the driver it should all look like an
ioctl. That way the driver doesn't have to deal with multiple points of entry.

Regards,

Hans


-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG
--
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


OT (slightly): is anyone on this list working on camera capture for i.MX51?

2010-04-08 Thread Chris Simmonds

Hi,

I know that this is off topic because (alas) the i.MX51 support is not 
in the mainline kernel. However, if anyone is working with the camera 
sensor interfaces on this device I would be very interested to talk to 
them, on list or off, because I am stuck! CSI1 works fine, but CSI2 
refuses to do anything...


Bye for now,
Chris

--
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: [RFC2] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread David Härdeman
On Thu, Apr 08, 2010 at 02:10:40AM -0300, Mauro Carvalho Chehab wrote:
 David Härdeman wrote:
  
  o The RX decoding is now handled via a workqueue (I can break that up into a
separate patch later, but I think it helps the discussion to have it in 
  for
now), with inspiration from Andy's code.
 
 I'm in doubt about that. the workqueue is called just after an event. this 
 means
 that, just after every IRQ trigger (assuming the worse case), the workqueue 
 will 
 be called.

No

 On the previous code, it is drivers responsibility to call the function that 
 de-queue. On saa7134, I've scheduled it to wake after 15 ms. So, instead of
 32 wakeups, just one is done, and the additional delay introduced by it is not
 enough to disturb the user.

It's still the case with my patch, the ir_raw_event_handle() function is 
still there and it will call schedule_work().

 o int's are still used to represent pulse/space durations in ms.
   Mauro and I seem to disagree on this one but I'm right :)
 
 :)
 
 We both have different opinions on that. I didn't hear a good argument from 
 you
 why your're right and I am wrong ;)
 
 Maybe we can try to make a deal on it.
 
 What you're really doing is:
 
 struct rc_event {
   u32 mark : 1;
   u32 duration :31;   /* in microsseconds */
 };
 
 Please, correct me if I'm wrong, but I suspect that the technical reasons 
 behind your
 proposal are:
   1) to save space at kfifo and argument exchange with the functions;
   2) nanoseconds is too short for a carrier at the order of 10^4 
   Hz;
 
 My proposal is to do something like:
 
 struct rc_event {
   enum rc_event_type type;
   u64 duration/* in nanoseconds */
 
 My rationale are:
   1) To make the decoder code less obfuscated;

Subjective

   2) To use the same time measurement as used on kernel timers, avoiding 
 an uneeded division
 for IRQ and polling-based devices.

Are you sure you don't want to rewrite ir_raw_event_store_edge() and 
ir_raw_event_store() in assembly?
 
 It might have some other non-technical issues, like foo/bar uses this/that, 
 this means less changes
 on some code, etc, but we shouldn't consider those non-technical issues when 
 discussing
 the architecture.
 
 So, here's the deal:

 
 Let's do something in-between. While I still think that using a different 
 measure for
 duration will add an unnecessary runtime conversion from kernel ktime into
 microsseconds, for me, the most important point is to avoid obfuscating the 
 code.
 
 So, we can define a opaque type:
 
 typedef u32 mark_duration_t;
 
 To represent the rc_event struct (this isn't a number anymore - it is a 
 struct with one
 bit for mark/space and 31 bits for unsigned duration). The use of an opaque 
 type may
 avoid people to do common mistakes.

I've seldom seen a case where a typedef gobbledygook is considered 
clearer than a native data type.

 And use some macros to convert from this type, like:
   
 #define DURATION(mark_duration)   abs(mark_duration)
 #define MARK(duration)(abs(duration))
 #define SPACE(duration)   (-abs(duration))
 #define IS_MARK(mark_duration)((duration  0) ? 1 : 0)
 #define IS_SPACE(mark_duration)   ((duration  0) ? 1 : 0)
 #define DURATION(mark_duration)   abs(mark_duration)
 #define TO_UNITS(mark_duration, unit) \
   do { \
   a = DIV_ROUND_CLOSEST(DURATION(mark_duration), unit); \
   a = (mark_duration  0) ? -a: a; \
   } while (0)
 
 And use it along the decoders:

If you think a couple of defines would make it that much clearer, I can 
add some defines. If the division in ktime_us_delta() worries you that 
much, I can avoid it as well.

So how about:

s64 duration; /* signed to represent pulse/space, in ns */

This is the return value from ktime subtraction, so no conversion 
necessary. Then I'll also add defines along your lines.

New patch coming up...

-- 
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


Scan-file for uk-Aberdare

2010-04-08 Thread Mike Martin
Attached is a working scan file for uk-Aberdare post switchover


uk-Aberdare_dso
Description: Binary data


[RFC3] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread David Härdeman
drivers/media/IR/ir-raw-event.c is currently written with the assumption 
that all raw hardware will generate events only on state change (i.e.  
when a pulse or space starts).

However, some hardware (like mceusb, probably the most popular IR receiver
out there) only generates duration data (and that data is buffered so using
any kind of timing on the data is futile).

Furthermore, using signed int's to represent pulse/space durations in ms
is a well-known approach to anyone with experience in writing ir decoders.

This patch (which has been tested this time) is still a RFC on my proposed
interface changes.

Changes since last version:

o s64's are used to represent pulse/space durations in ns.

o Lots of #defines are used in the decoders

o Refreshed to apply cleanly on top of Mauro's current git tree

o Jon's comments wrt. interrupt-context safe functions have been added

Index: ir/drivers/media/IR/ir-raw-event.c
===
--- ir.orig/drivers/media/IR/ir-raw-event.c 2010-04-08 12:30:28.036098192 
+0200
+++ ir/drivers/media/IR/ir-raw-event.c  2010-04-08 12:45:19.780145403 +0200
@@ -15,9 +15,10 @@
 #include media/ir-core.h
 #include linux/workqueue.h
 #include linux/spinlock.h
+#include linux/sched.h
 
-/* Define the max number of bit transitions per IR keycode */
-#define MAX_IR_EVENT_SIZE  256
+/* Define the max number of pulse/space transitions to buffer */
+#define MAX_IR_EVENT_SIZE  512
 
 /* Used to handle IR raw handler extensions */
 static LIST_HEAD(ir_raw_handler_list);
@@ -53,19 +54,30 @@
 /* Used to load the decoders */
 static struct work_struct wq_load;
 
+static void ir_raw_event_work(struct work_struct *work)
+{
+   s64 d;
+   struct ir_raw_event_ctrl *raw =
+   container_of(work, struct ir_raw_event_ctrl, rx_work);
+
+   while (kfifo_out(raw-kfifo, d, sizeof(d)) == sizeof(d))
+   RUN_DECODER(decode, raw-input_dev, d);
+}
+
 int ir_raw_event_register(struct input_dev *input_dev)
 {
struct ir_input_dev *ir = input_get_drvdata(input_dev);
-   int rc, size;
+   int rc;
 
ir-raw = kzalloc(sizeof(*ir-raw), GFP_KERNEL);
if (!ir-raw)
return -ENOMEM;
 
-   size = sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE * 2;
-   size = roundup_pow_of_two(size);
+   ir-raw-input_dev = input_dev;
+   INIT_WORK(ir-raw-rx_work, ir_raw_event_work);
 
-   rc = kfifo_alloc(ir-raw-kfifo, size, GFP_KERNEL);
+   rc = kfifo_alloc(ir-raw-kfifo, sizeof(s64) * MAX_IR_EVENT_SIZE,
+GFP_KERNEL);
if (rc  0) {
kfree(ir-raw);
ir-raw = NULL;
@@ -90,6 +102,7 @@
if (!ir-raw)
return;
 
+   cancel_work_sync(ir-raw-rx_work);
RUN_DECODER(raw_unregister, input_dev);
 
kfifo_free(ir-raw-kfifo);
@@ -97,74 +110,90 @@
ir-raw = NULL;
 }
 
-int ir_raw_event_store(struct input_dev *input_dev, enum raw_event_type type)
+/**
+ * ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
+ * @input_dev: the struct input_dev device descriptor
+ * @duration:  duration of the pulse or space in ns
+ *
+ * This routine (which may be called from an interrupt context) stores a
+ * pulse/space duration for the raw ir decoding state machines. Pulses are
+ * signalled as positive values and spaces as negative values. A zero value
+ * will reset the decoding state machines.
+ */
+int ir_raw_event_store(struct input_dev *input_dev, s64 duration)
 {
-   struct ir_input_dev *ir = input_get_drvdata(input_dev);
-   struct timespec ts;
-   struct ir_raw_event event;
-   int rc;
+   struct ir_input_dev *ir = input_get_drvdata(input_dev);
 
if (!ir-raw)
return -EINVAL;
 
-   event.type = type;
-   event.delta.tv_sec = 0;
-   event.delta.tv_nsec = 0;
+   if (kfifo_in(ir-raw-kfifo, duration, sizeof(duration)) != 
sizeof(duration))
+   return -ENOMEM;
 
-   ktime_get_ts(ts);
+   return 0;
+}
+EXPORT_SYMBOL_GPL(ir_raw_event_store);
 
-   if (timespec_equal(ir-raw-last_event, event.delta))
-   event.type |= IR_START_EVENT;
-   else
-   event.delta = timespec_sub(ts, ir-raw-last_event);
+/**
+ * ir_raw_event_store_edge() - notify raw ir decoders of the start of a 
pulse/space
+ * @input_dev: the struct input_dev device descriptor
+ * @type:  the type of the event that has occurred
+ *
+ * This routine (which may be called from an interrupt context) is used to
+ * store the beginning of an ir pulse or space (or the start/end of ir
+ * reception) for the raw ir decoding state machines. This is used by
+ * hardware which does not provide durations directly but only interrupts
+ * (or similar events) on state change.
+ */
+int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type 
type)
+{
+   

[PATCH 11/16] V4L/DVB: DVB: ngene, remove unused #include linux/version.h

2010-04-08 Thread Huang Weiyi
Remove unused #include linux/version.h('s) in
  drivers/media/dvb/ngene/ngene-core.c

Signed-off-by: Huang Weiyi weiyi.hu...@gmail.com
---
 drivers/media/dvb/ngene/ngene-core.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/ngene/ngene-core.c 
b/drivers/media/dvb/ngene/ngene-core.c
index 645e8b8..6dc567b 100644
--- a/drivers/media/dvb/ngene/ngene-core.c
+++ b/drivers/media/dvb/ngene/ngene-core.c
@@ -37,7 +37,6 @@
 #include linux/pci_ids.h
 #include linux/smp_lock.h
 #include linux/timer.h
-#include linux/version.h
 #include linux/byteorder/generic.h
 #include linux/firmware.h
 #include linux/vmalloc.h
-- 
1.6.1.3

--
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: new V4L control framework

2010-04-08 Thread Pawel Osciak
Hi Hans,

Hans Verkuil wrote:

BTW, I've also completely overhauled the vivi driver. I've used it to test
the control handling, but I took the opportunity to do a big clean up of that
driver. The combination of vivi + qv4l2 made testing of the more unusual
integer64 and string control types much easier.

This is a bit off-topic, but I feel that any clean-up of vivi would more than
welcome. I use it for testing many different things as well. It would be great
if you could release those cleanup patches separately (without control-related
code)... Please let me know if you'd be planning to do something like that
in the (near) future. Thanks!


Best regards
--
Pawel Osciak
Linux Platform Group
Samsung Poland RD Center



--
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 06/16] V4L/DVB: vpif: remove unused #include linux/version.h

2010-04-08 Thread Huang Weiyi
Remove unused #include linux/version.h('s) in
  drivers/media/video/davinci/vpif_capture.c
  drivers/media/video/davinci/vpif_display.c

Signed-off-by: Huang Weiyi weiyi.hu...@gmail.com
---
 drivers/media/video/davinci/vpif_capture.c |1 -
 drivers/media/video/davinci/vpif_display.c |1 -
 2 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/davinci/vpif_capture.c 
b/drivers/media/video/davinci/vpif_capture.c
index 2e5a7fb..f74b551 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -33,7 +33,6 @@
 #include linux/i2c.h
 #include linux/platform_device.h
 #include linux/io.h
-#include linux/version.h
 #include linux/slab.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
diff --git a/drivers/media/video/davinci/vpif_display.c 
b/drivers/media/video/davinci/vpif_display.c
index 13c3a1b..f8cd5e5 100644
--- a/drivers/media/video/davinci/vpif_display.c
+++ b/drivers/media/video/davinci/vpif_display.c
@@ -29,7 +29,6 @@
 #include linux/i2c.h
 #include linux/platform_device.h
 #include linux/io.h
-#include linux/version.h
 #include linux/slab.h
 
 #include asm/irq.h
-- 
1.6.1.3

--
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: [RFC3] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread Mauro Carvalho Chehab
David Härdeman wrote:

Your're fast!

OK, the code looks good. I'll test and apply it, if it passes on the test. 
The only missed thing is the comment about the kfifo size (see the email
I just sent). If you prefer, I can add a one line comment when applying it,
to avoid you to re-send the code.

 drivers/media/IR/ir-raw-event.c is currently written with the assumption 
 that all raw hardware will generate events only on state change (i.e.  
 when a pulse or space starts).
 
 However, some hardware (like mceusb, probably the most popular IR receiver
 out there) only generates duration data (and that data is buffered so using
 any kind of timing on the data is futile).
 
 Furthermore, using signed int's to represent pulse/space durations in ms
 is a well-known approach to anyone with experience in writing ir decoders.
 
 This patch (which has been tested this time) is still a RFC on my proposed
 interface changes.
 
 Changes since last version:
 
 o s64's are used to represent pulse/space durations in ns.
 
 o Lots of #defines are used in the decoders
 
 o Refreshed to apply cleanly on top of Mauro's current git tree
 
 o Jon's comments wrt. interrupt-context safe functions have been added
 
 Index: ir/drivers/media/IR/ir-raw-event.c
 ===
 --- ir.orig/drivers/media/IR/ir-raw-event.c   2010-04-08 12:30:28.036098192 
 +0200
 +++ ir/drivers/media/IR/ir-raw-event.c2010-04-08 12:45:19.780145403 
 +0200
 @@ -15,9 +15,10 @@
  #include media/ir-core.h
  #include linux/workqueue.h
  #include linux/spinlock.h
 +#include linux/sched.h
  
 -/* Define the max number of bit transitions per IR keycode */
 -#define MAX_IR_EVENT_SIZE256
 +/* Define the max number of pulse/space transitions to buffer */
 +#define MAX_IR_EVENT_SIZE  512
  
  /* Used to handle IR raw handler extensions */
  static LIST_HEAD(ir_raw_handler_list);
 @@ -53,19 +54,30 @@
  /* Used to load the decoders */
  static struct work_struct wq_load;
  
 +static void ir_raw_event_work(struct work_struct *work)
 +{
 + s64 d;
 + struct ir_raw_event_ctrl *raw =
 + container_of(work, struct ir_raw_event_ctrl, rx_work);
 +
 + while (kfifo_out(raw-kfifo, d, sizeof(d)) == sizeof(d))
 + RUN_DECODER(decode, raw-input_dev, d);
 +}
 +
  int ir_raw_event_register(struct input_dev *input_dev)
  {
   struct ir_input_dev *ir = input_get_drvdata(input_dev);
 - int rc, size;
 + int rc;
  
   ir-raw = kzalloc(sizeof(*ir-raw), GFP_KERNEL);
   if (!ir-raw)
   return -ENOMEM;
  
 - size = sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE * 2;
 - size = roundup_pow_of_two(size);
 + ir-raw-input_dev = input_dev;
 + INIT_WORK(ir-raw-rx_work, ir_raw_event_work);
  
 - rc = kfifo_alloc(ir-raw-kfifo, size, GFP_KERNEL);
 + rc = kfifo_alloc(ir-raw-kfifo, sizeof(s64) * MAX_IR_EVENT_SIZE,
 +  GFP_KERNEL);
   if (rc  0) {
   kfree(ir-raw);
   ir-raw = NULL;
 @@ -90,6 +102,7 @@
   if (!ir-raw)
   return;
  
 + cancel_work_sync(ir-raw-rx_work);
   RUN_DECODER(raw_unregister, input_dev);
  
   kfifo_free(ir-raw-kfifo);
 @@ -97,74 +110,90 @@
   ir-raw = NULL;
  }
  
 -int ir_raw_event_store(struct input_dev *input_dev, enum raw_event_type type)
 +/**
 + * ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
 + * @input_dev:   the struct input_dev device descriptor
 + * @duration:duration of the pulse or space in ns
 + *
 + * This routine (which may be called from an interrupt context) stores a
 + * pulse/space duration for the raw ir decoding state machines. Pulses are
 + * signalled as positive values and spaces as negative values. A zero value
 + * will reset the decoding state machines.
 + */
 +int ir_raw_event_store(struct input_dev *input_dev, s64 duration)
  {
 - struct ir_input_dev *ir = input_get_drvdata(input_dev);
 - struct timespec ts;
 - struct ir_raw_event event;
 - int rc;
 + struct ir_input_dev *ir = input_get_drvdata(input_dev);
  
   if (!ir-raw)
   return -EINVAL;
  
 - event.type = type;
 - event.delta.tv_sec = 0;
 - event.delta.tv_nsec = 0;
 + if (kfifo_in(ir-raw-kfifo, duration, sizeof(duration)) != 
 sizeof(duration))
 + return -ENOMEM;
  
 - ktime_get_ts(ts);
 + return 0;
 +}
 +EXPORT_SYMBOL_GPL(ir_raw_event_store);
  
 - if (timespec_equal(ir-raw-last_event, event.delta))
 - event.type |= IR_START_EVENT;
 - else
 - event.delta = timespec_sub(ts, ir-raw-last_event);
 +/**
 + * ir_raw_event_store_edge() - notify raw ir decoders of the start of a 
 pulse/space
 + * @input_dev:   the struct input_dev device descriptor
 + * @type:the type of the event that has occurred
 + *
 + * This routine (which may be called from an interrupt context) is used to
 

Re: [RFC3] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread Mauro Carvalho Chehab
David Härdeman wrote:
 drivers/media/IR/ir-raw-event.c is currently written with the assumption 
 that all raw hardware will generate events only on state change (i.e.  
 when a pulse or space starts).
 
 However, some hardware (like mceusb, probably the most popular IR receiver
 out there) only generates duration data (and that data is buffered so using
 any kind of timing on the data is futile).
 
 Furthermore, using signed int's to represent pulse/space durations in ms
 is a well-known approach to anyone with experience in writing ir decoders.
 
 This patch (which has been tested this time) is still a RFC on my proposed
 interface changes.
 
 Changes since last version:
 
 o s64's are used to represent pulse/space durations in ns.
 
 o Lots of #defines are used in the decoders
 
 o Refreshed to apply cleanly on top of Mauro's current git tree
 
 o Jon's comments wrt. interrupt-context safe functions have been added
 

Ok, tested it with a variety of NEC/NEC extended/RC-5 IR's I have, with the
saa7134 hardware. All worked.

There's just a few checkpatch.pl complains, and the most important thing:

It lacks your SOB ;)

Please fix the checkpatch.pl errors, add a kfifo size comment and your SOB
and resend it to me (or, if you prefer, just send your SOB. I can take care
of the rest, as they're just trivial things).

-- 

Cheers,
Mauro
--
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: [RFC2] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread Jon Smirl
On Thu, Apr 8, 2010 at 1:10 AM, Mauro Carvalho Chehab
mche...@infradead.org wrote:
 David Härdeman wrote:
 drivers/media/IR/ir-raw-event.c is currently written with the assumption
 that all raw hardware will generate events only on state change (i.e.
 when a pulse or space starts).

 However, some hardware (like mceusb, probably the most popular IR receiver
 out there) only generates duration data (and that data is buffered so using
 any kind of timing on the data is futile).

 Furthermore, using signed int's to represent pulse/space durations in ms
 is a well-known approach to anyone with experience in writing ir decoders.

 This patch (which has been tested this time) is still a RFC on my proposed
 interface changes.

 Changes since last version:

 o RC5x and NECx support no longer added in patch (separate patches to follow)

 o The use of a kfifo has been left given feedback from Jon, Andy, Mauro

 Ok.

 o The RX decoding is now handled via a workqueue (I can break that up into a
   separate patch later, but I think it helps the discussion to have it in for
   now), with inspiration from Andy's code.

 I'm in doubt about that. the workqueue is called just after an event. this 
 means
 that, just after every IRQ trigger (assuming the worse case), the workqueue 
 will
 be called.

 On the previous code, it is drivers responsibility to call the function that
 de-queue. On saa7134, I've scheduled it to wake after 15 ms. So, instead of
 32 wakeups, just one is done, and the additional delay introduced by it is not
 enough to disturb the user.

The wakeup is variable when the default thread is used. My quad core
desktop wakes up on every pulse. My embedded system wakes up about
every 15 pulses. The embedded system called schedule_work() fifteen
times from the IRQ, but the kernel collapsed them into a single
wakeup. I'd stick with the default thread and let the kernel get
around to processing IR whenever it has some time.

A workqueue has to be used at some point in the system. The input
subsystem calls that send messages to user space can't be called from
interrupt context.  I believe in handing off to the workqueue as soon
as possible for IR signals.

Keep this code in the core to simplify writing the drivers. My GPIO
timer driver example is very simple.

If you're worried about performance, none of this code matters. What
is more important is localizing memory accesses to avoid processor
cache misses. A cache miss can equal 1000 divides.


   o Separate reset operations are no longer added to decoders, a duration of
   zero is instead used to signal a reset (which allows the reset request to
   be inserted into the kfifo).

 o Not sent using quilt...Mauro, does it still trip up your MUA?

 Thank you! Btw, git mailsend doesn't have any troubles.

 Not changed:

 o int's are still used to represent pulse/space durations in ms. Mauro and I
   seem to disagree on this one but I'm right :)

 :)

 We both have different opinions on that. I didn't hear a good argument from 
 you
 why your're right and I am wrong ;)

 Maybe we can try to make a deal on it.

 What you're really doing is:

 struct rc_event {
        u32     mark : 1;
        u32     duration :31;   /* in microsseconds */
 };

 Please, correct me if I'm wrong, but I suspect that the technical reasons 
 behind your
 proposal are:
        1) to save space at kfifo and argument exchange with the functions;
        2) nanoseconds is too short for a carrier at the order of 10^4 Hz;

 My proposal is to do something like:

 struct rc_event {
        enum rc_event_type type;
        u64 duration            /* in nanoseconds */

 My rationale are:
        1) To make the decoder code less obfuscated;
        2) To use the same time measurement as used on kernel timers, avoiding 
 an uneeded division
 for IRQ and polling-based devices.

 It might have some other non-technical issues, like foo/bar uses this/that, 
 this means less changes
 on some code, etc, but we shouldn't consider those non-technical issues when 
 discussing
 the architecture.

 So, here's the deal:

 Let's do something in-between. While I still think that using a different 
 measure for
 duration will add an unnecessary runtime conversion from kernel ktime into
 microsseconds, for me, the most important point is to avoid obfuscating the 
 code.

 So, we can define a opaque type:

 typedef u32 mark_duration_t;

 To represent the rc_event struct (this isn't a number anymore - it is a 
 struct with one
 bit for mark/space and 31 bits for unsigned duration). The use of an opaque 
 type may
 avoid people to do common mistakes.

 And use some macros to convert from this type, like:

 #define DURATION(mark_duration) abs(mark_duration)
 #define MARK(duration)  (abs(duration))
 #define SPACE(duration) (-abs(duration))
 #define IS_MARK(mark_duration)  ((duration  0) ? 1 : 0)
 #define IS_SPACE(mark_duration) ((duration  0) ? 1 : 0)
 #define DURATION(mark_duration) abs(mark_duration)
 #define 

Capturing errors when doing v4l2_read

2010-04-08 Thread Pablo Baena
I'm trying to detect when a user unplugs a camera while I'm doing
v4l2_read, but even when I get logs like this:

libv4l2: error queuing buf 0: No such device
libv4l2: error queuing buf 1: No such device
libv4l2: error queuing buf 2: No such device
libv4l2: error dequeuing buf: Input/output error

errno is not containing any errors, and I get a previously retrieved
buffer anyway.

Is this correct behaviour? Shouldn't it return an error? For the
moment, can I do something to workaround this?

-- 
The Linux philosophy is 'Laugh in the face of danger'. Oops. Wrong
One. 'Do it yourself'. Yes, that's it.
--
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: [RFC2] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread Mauro Carvalho Chehab
Jon Smirl wrote:
 On Thu, Apr 8, 2010 at 1:10 AM, Mauro Carvalho Chehab
 mche...@infradead.org wrote:
 David Härdeman wrote:
 drivers/media/IR/ir-raw-event.c is currently written with the assumption
 that all raw hardware will generate events only on state change (i.e.
 when a pulse or space starts).

 However, some hardware (like mceusb, probably the most popular IR receiver
 out there) only generates duration data (and that data is buffered so using
 any kind of timing on the data is futile).

 Furthermore, using signed int's to represent pulse/space durations in ms
 is a well-known approach to anyone with experience in writing ir decoders.

 This patch (which has been tested this time) is still a RFC on my proposed
 interface changes.

 Changes since last version:

 o RC5x and NECx support no longer added in patch (separate patches to 
 follow)

 o The use of a kfifo has been left given feedback from Jon, Andy, Mauro
 Ok.

 o The RX decoding is now handled via a workqueue (I can break that up into a
   separate patch later, but I think it helps the discussion to have it in 
 for
   now), with inspiration from Andy's code.
 I'm in doubt about that. the workqueue is called just after an event. this 
 means
 that, just after every IRQ trigger (assuming the worse case), the workqueue 
 will
 be called.

 On the previous code, it is drivers responsibility to call the function that
 de-queue. On saa7134, I've scheduled it to wake after 15 ms. So, instead of
 32 wakeups, just one is done, and the additional delay introduced by it is 
 not
 enough to disturb the user.
 
 The wakeup is variable when the default thread is used. My quad core
 desktop wakes up on every pulse. My embedded system wakes up about
 every 15 pulses. The embedded system called schedule_work() fifteen
 times from the IRQ, but the kernel collapsed them into a single
 wakeup. I'd stick with the default thread and let the kernel get
 around to processing IR whenever it has some time.

Makes sense.

 A workqueue has to be used at some point in the system. The input
 subsystem calls that send messages to user space can't be called from
 interrupt context.  I believe in handing off to the workqueue as soon
 as possible for IR signals.

I'm ok on using a workqueue for it.
 
 Keep this code in the core to simplify writing the drivers. My GPIO
 timer driver example is very simple.
 
 If you're worried about performance, none of this code matters. What
 is more important is localizing memory accesses to avoid processor
 cache misses. A cache miss can equal 1000 divides.

Agreed.


-- 

Cheers,
Mauro
--
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: [RFC2] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread Mauro Carvalho Chehab
David Härdeman wrote:
 On Thu, Apr 08, 2010 at 08:50:48AM -0300, Mauro Carvalho Chehab wrote:
 -   size = sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE * 2;
 -   size = roundup_pow_of_two(size);
 +   ir-raw-input_dev = input_dev;
 +   INIT_WORK(ir-raw-rx_work, ir_raw_event_work);

 -   rc = kfifo_alloc(ir-raw-kfifo, size, GFP_KERNEL);
 +   rc = kfifo_alloc(ir-raw-kfifo, sizeof(int) * MAX_IR_EVENT_SIZE,
 +GFP_KERNEL);
 kfifo logic requires a power of two buffer to work, so, please keep the
 original roundup_pow_of_two() logic, or add a comment before 
 MAX_IR_EVENT_SIZE.
 
 No, kfifo_alloc() takes care of the rounding up. See the code for 
 kfifo_alloc() in kernel/kfifo.c.
 
Ok.

-- 

Cheers,
Mauro
--
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 11/16] V4L/DVB: DVB: ngene, remove unused #include linux/version.h

2010-04-08 Thread Devin Heitmueller
On Thu, Apr 8, 2010 at 7:50 AM, Huang Weiyi weiyi.hu...@gmail.com wrote:
 Remove unused #include linux/version.h('s) in
  drivers/media/dvb/ngene/ngene-core.c

 Signed-off-by: Huang Weiyi weiyi.hu...@gmail.com
 ---
  drivers/media/dvb/ngene/ngene-core.c |    1 -
  1 files changed, 0 insertions(+), 1 deletions(-)

 diff --git a/drivers/media/dvb/ngene/ngene-core.c 
 b/drivers/media/dvb/ngene/ngene-core.c
 index 645e8b8..6dc567b 100644
 --- a/drivers/media/dvb/ngene/ngene-core.c
 +++ b/drivers/media/dvb/ngene/ngene-core.c
 @@ -37,7 +37,6 @@
  #include linux/pci_ids.h
  #include linux/smp_lock.h
  #include linux/timer.h
 -#include linux/version.h
  #include linux/byteorder/generic.h
  #include linux/firmware.h
  #include linux/vmalloc.h

Hello Huang,

I just wanted to let you know that KernelLabs has a rather large
project ongoing to clean up the ngene driver.  So while I have no
objection to this patch in principle, please be advised that there is
not much value in doing additional cleanup to that driver as it is
likely to be redundant (and will just increase our work in merging the
changes upstream).

Cheers,

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
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: [RFC2] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread David Härdeman
On Thu, Apr 08, 2010 at 10:06:53AM -0300, Mauro Carvalho Chehab wrote:
 Jon Smirl wrote:
  On Thu, Apr 8, 2010 at 1:10 AM, Mauro Carvalho Chehab
  mche...@infradead.org wrote:
  On the previous code, it is drivers responsibility to call the 
  function that
  de-queue. On saa7134, I've scheduled it to wake after 15 ms. So, instead of
  32 wakeups, just one is done, and the additional delay introduced by it is 
  not
  enough to disturb the user.
  
  The wakeup is variable when the default thread is used. My quad core
  desktop wakes up on every pulse. My embedded system wakes up about
  every 15 pulses. The embedded system called schedule_work() fifteen
  times from the IRQ, but the kernel collapsed them into a single
  wakeup. I'd stick with the default thread and let the kernel get
  around to processing IR whenever it has some time.
 
 Makes sense.

Given Jon's experience, it would perhaps make sense to remove 
ir_raw_event_handle() and call schedule_work() from every call to 
ir_raw_event_store()?

One thing less for IR drivers to care about...

-- 
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] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread David Härdeman
drivers/media/IR/ir-raw-event.c is currently written with the assumption
that all raw hardware will generate events only on state change (i.e.
when a pulse or space starts).

However, some hardware (like mceusb, probably the most popular IR receiver
out there) only generates duration data (and that data is buffered so using
any kind of timing on the data is futile).

Furthermore, using signed int's to represent pulse/space durations is a
well-known approach when writing ir decoders.

With this patch:

s64 int's are used to represent pulse/space durations in ns

a workqueue is used to decode the ir protocols outside of interrupt context

#defines are added to make decoders clearer

decoder reset is implemented by passing a zero duration to the kfifo queue

and decoders are updated accordingly

(checkpatch is content with everything but the line lengths, Mauro, feel
free to fixup those if you feel it is important)

Signed-off-by: David Härdeman da...@hardeman.nu

Index: ir/drivers/media/IR/ir-raw-event.c
===
--- ir.orig/drivers/media/IR/ir-raw-event.c 2010-04-08 12:30:28.036098192 
+0200
+++ ir/drivers/media/IR/ir-raw-event.c  2010-04-08 12:45:19.780145403 +0200
@@ -15,9 +15,10 @@
 #include media/ir-core.h
 #include linux/workqueue.h
 #include linux/spinlock.h
+#include linux/sched.h
 
-/* Define the max number of bit transitions per IR keycode */
-#define MAX_IR_EVENT_SIZE  256
+/* Define the max number of pulse/space transitions to buffer */
+#define MAX_IR_EVENT_SIZE  512
 
 /* Used to handle IR raw handler extensions */
 static LIST_HEAD(ir_raw_handler_list);
@@ -53,19 +54,30 @@
 /* Used to load the decoders */
 static struct work_struct wq_load;
 
+static void ir_raw_event_work(struct work_struct *work)
+{
+   s64 d;
+   struct ir_raw_event_ctrl *raw =
+   container_of(work, struct ir_raw_event_ctrl, rx_work);
+
+   while (kfifo_out(raw-kfifo, d, sizeof(d)) == sizeof(d))
+   RUN_DECODER(decode, raw-input_dev, d);
+}
+
 int ir_raw_event_register(struct input_dev *input_dev)
 {
struct ir_input_dev *ir = input_get_drvdata(input_dev);
-   int rc, size;
+   int rc;
 
ir-raw = kzalloc(sizeof(*ir-raw), GFP_KERNEL);
if (!ir-raw)
return -ENOMEM;
 
-   size = sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE * 2;
-   size = roundup_pow_of_two(size);
+   ir-raw-input_dev = input_dev;
+   INIT_WORK(ir-raw-rx_work, ir_raw_event_work);
 
-   rc = kfifo_alloc(ir-raw-kfifo, size, GFP_KERNEL);
+   rc = kfifo_alloc(ir-raw-kfifo, sizeof(s64) * MAX_IR_EVENT_SIZE,
+GFP_KERNEL);
if (rc  0) {
kfree(ir-raw);
ir-raw = NULL;
@@ -90,6 +102,7 @@
if (!ir-raw)
return;
 
+   cancel_work_sync(ir-raw-rx_work);
RUN_DECODER(raw_unregister, input_dev);
 
kfifo_free(ir-raw-kfifo);
@@ -97,74 +110,90 @@
ir-raw = NULL;
 }
 
-int ir_raw_event_store(struct input_dev *input_dev, enum raw_event_type type)
+/**
+ * ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
+ * @input_dev: the struct input_dev device descriptor
+ * @duration:  duration of the pulse or space in ns
+ *
+ * This routine (which may be called from an interrupt context) stores a
+ * pulse/space duration for the raw ir decoding state machines. Pulses are
+ * signalled as positive values and spaces as negative values. A zero value
+ * will reset the decoding state machines.
+ */
+int ir_raw_event_store(struct input_dev *input_dev, s64 duration)
 {
-   struct ir_input_dev *ir = input_get_drvdata(input_dev);
-   struct timespec ts;
-   struct ir_raw_event event;
-   int rc;
+   struct ir_input_dev *ir = input_get_drvdata(input_dev);
 
if (!ir-raw)
return -EINVAL;
 
-   event.type = type;
-   event.delta.tv_sec = 0;
-   event.delta.tv_nsec = 0;
+   if (kfifo_in(ir-raw-kfifo, duration, sizeof(duration)) != 
sizeof(duration))
+   return -ENOMEM;
 
-   ktime_get_ts(ts);
+   return 0;
+}
+EXPORT_SYMBOL_GPL(ir_raw_event_store);
 
-   if (timespec_equal(ir-raw-last_event, event.delta))
-   event.type |= IR_START_EVENT;
-   else
-   event.delta = timespec_sub(ts, ir-raw-last_event);
+/**
+ * ir_raw_event_store_edge() - notify raw ir decoders of the start of a 
pulse/space
+ * @input_dev: the struct input_dev device descriptor
+ * @type:  the type of the event that has occurred
+ *
+ * This routine (which may be called from an interrupt context) is used to
+ * store the beginning of an ir pulse or space (or the start/end of ir
+ * reception) for the raw ir decoding state machines. This is used by
+ * hardware which does not provide durations directly but only interrupts
+ * (or similar events) on state change.
+ */
+int 

Re: [RFC2] Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread Mauro Carvalho Chehab
David Härdeman wrote:
 On Thu, Apr 08, 2010 at 10:06:53AM -0300, Mauro Carvalho Chehab wrote:
 Jon Smirl wrote:
 On Thu, Apr 8, 2010 at 1:10 AM, Mauro Carvalho Chehab
 mche...@infradead.org wrote:
 On the previous code, it is drivers responsibility to call the 
 function that
 de-queue. On saa7134, I've scheduled it to wake after 15 ms. So, instead of
 32 wakeups, just one is done, and the additional delay introduced by it is 
 not
 enough to disturb the user.
 The wakeup is variable when the default thread is used. My quad core
 desktop wakes up on every pulse. My embedded system wakes up about
 every 15 pulses. The embedded system called schedule_work() fifteen
 times from the IRQ, but the kernel collapsed them into a single
 wakeup. I'd stick with the default thread and let the kernel get
 around to processing IR whenever it has some time.
 Makes sense.
 
 Given Jon's experience, it would perhaps make sense to remove 
 ir_raw_event_handle() and call schedule_work() from every call to 
 ir_raw_event_store()?
 
 One thing less for IR drivers to care about...

Maybe, on a separate patch, but let's do it by the end of the changes,
to let people to give us some feedback about the practical effects
on the users side, and the corresponding perf impacts. 

I won't mind to move the mod_timer stuff from saa7134 to the core, 
as a way to easy this change.

-- 

Cheers,
Mauro
--
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: RFC: exposing controls in sysfs

2010-04-08 Thread Lars Hanisch

Am 08.04.2010 02:47, schrieb Mike Isely:

On Thu, 8 Apr 2010, hermann pitton wrote:


Hi,

Am Mittwoch, den 07.04.2010, 20:50 +0200 schrieb Lars Hanisch:

Am 06.04.2010 16:33, schrieb Mike Isely:

[snip]


Mike, do you know of anyone actively using that additional information?


Yes.

The VDR project at one time implemented a plugin to directly interface
to the pvrusb2 driver in this manner.  I do not know if it is still
being used since I don't maintain that plugin.


   Just FYI:
   The PVR USB2 device is now handled by the pvrinput-plugin, which uses only ioctls. The 
old pvrusb2-plugin is obsolete.

   http://projects.vdr-developer.org/projects/show/plg-pvrinput


Lars:

Thanks for letting me know about that - until this message I had no idea
if VDR was still using that interface.




Regards,
Lars.


[snip]

thanks Lars.

Mike is really caring and went out for even any most obscure tuner bit
to help to improve such stuff in the past, when we have been without any
data sheets.


Hermann:

You might have me confused with Mike Krufky there - he's the one who did
so much of the tuner driver overhauling in v4l-dvb in the past.




To open second, maybe third and even forth ways for apps to use a
device, likely going out of sync soon, does only load maintenance work
without real gain.


Well it was an experiment at the time to see how well such a concept
would work.  I had done it in a way to minimize maintenance load going
forward.  On both counts I feel the interface actually has done very
well, nonstandard though it may be.

I still get the general impression that the user community really has
liked the sysfs interface, but the developers never really got very fond
of it :-(


 From my point of view as an application developer I never tried to use
sysfs at all. I admit that it's nice to use from a shell script in known
environments (like setting up a card for recording with cat etc.) but what
about error handling? How will I (the script) know, if setting a control is
successful or not? Currently I don't know if v4l2-ctl returns some useful
exit code, but with ioctls it's a lot easier to track errors.
 I never liked to handle with directories and files, reading and writing if
there's a function which is doing the same thing in a much easier way. :-)

 But all this might be related to my not-really-present knowledge of using
sysfs in the right way.

 And reading other posts debugfs seems to be the better choice (just read
some articles on it to get a general survey of it).

Regards,
Lars.






We should stay sharp to discover something others don't want to let us
know about. All other ideas about markets are illusions. Or?

So, debugfs sounds much better than sysfs for my taste.

Any app and any driver, going out of sync on the latter, will remind us
that backward compat _must always be guaranteed_  ...

Or did change anything on that and is sysfs excluded from that rule?


Backwards compatibility is very important and thus any kind of new
interface deserves a lot of forethought to ensure that choices are made
in the present that people will regret in the future.  Making an
interface self-describing is one way that helps with compatibility: if
the app can discover on its own how to use the interface then it can
adapt to interface changes in the future.  I think a lot of people get
their brains so wrapped around the ioctl-way of doing things and then
they try to map that concept into a sysfs-like (or debugfs-like)
abstraction that they don't see how to naturally take advantage of what
is possible there.

   -Mike


--
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


[cron job] v4l-dvb daily build 2.6.22 and up: ERRORS, 2.6.16-2.6.21: WARNINGS

2010-04-08 Thread Hans Verkuil
This message is generated daily by a cron job that builds v4l-dvb for
the kernels and architectures in the list below.

Results of the daily build of v4l-dvb:

date:Thu Apr  8 19:00:16 CEST 2010
path:http://www.linuxtv.org/hg/v4l-dvb
changeset:   14561:7c0b887911cf
git master:   f6760aa024199cfbce564311dc4bc4d47b6fb349
git media-master: a6eb7bc8e0eea78f96ad1b0f0195ec52b88c6a00
gcc version:  i686-linux-gcc (GCC) 4.4.3
host hardware:x86_64
host os:  2.6.32.5

linux-2.6.32.6-armv5: OK
linux-2.6.33-armv5: OK
linux-2.6.34-rc1-armv5: OK
linux-2.6.32.6-armv5-davinci: WARNINGS
linux-2.6.33-armv5-davinci: WARNINGS
linux-2.6.34-rc1-armv5-davinci: WARNINGS
linux-2.6.32.6-armv5-ixp: WARNINGS
linux-2.6.33-armv5-ixp: WARNINGS
linux-2.6.34-rc1-armv5-ixp: WARNINGS
linux-2.6.32.6-armv5-omap2: WARNINGS
linux-2.6.33-armv5-omap2: WARNINGS
linux-2.6.34-rc1-armv5-omap2: WARNINGS
linux-2.6.22.19-i686: WARNINGS
linux-2.6.23.17-i686: WARNINGS
linux-2.6.24.7-i686: WARNINGS
linux-2.6.25.20-i686: WARNINGS
linux-2.6.26.8-i686: WARNINGS
linux-2.6.27.44-i686: WARNINGS
linux-2.6.28.10-i686: WARNINGS
linux-2.6.29.1-i686: WARNINGS
linux-2.6.30.10-i686: WARNINGS
linux-2.6.31.12-i686: WARNINGS
linux-2.6.32.6-i686: WARNINGS
linux-2.6.33-i686: WARNINGS
linux-2.6.34-rc1-i686: WARNINGS
linux-2.6.32.6-m32r: OK
linux-2.6.33-m32r: OK
linux-2.6.34-rc1-m32r: OK
linux-2.6.32.6-mips: WARNINGS
linux-2.6.33-mips: WARNINGS
linux-2.6.34-rc1-mips: WARNINGS
linux-2.6.32.6-powerpc64: WARNINGS
linux-2.6.33-powerpc64: WARNINGS
linux-2.6.34-rc1-powerpc64: WARNINGS
linux-2.6.22.19-x86_64: WARNINGS
linux-2.6.23.17-x86_64: WARNINGS
linux-2.6.24.7-x86_64: WARNINGS
linux-2.6.25.20-x86_64: WARNINGS
linux-2.6.26.8-x86_64: WARNINGS
linux-2.6.27.44-x86_64: WARNINGS
linux-2.6.28.10-x86_64: WARNINGS
linux-2.6.29.1-x86_64: WARNINGS
linux-2.6.30.10-x86_64: WARNINGS
linux-2.6.31.12-x86_64: WARNINGS
linux-2.6.32.6-x86_64: WARNINGS
linux-2.6.33-x86_64: WARNINGS
linux-2.6.34-rc1-x86_64: WARNINGS
linux-git-armv5: WARNINGS
linux-git-armv5-davinci: WARNINGS
linux-git-armv5-ixp: WARNINGS
linux-git-armv5-omap2: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: OK
linux-git-mips: WARNINGS
linux-git-powerpc64: WARNINGS
linux-git-x86_64: WARNINGS
spec: ERRORS
spec-git: ERRORS
sparse: ERRORS
linux-2.6.16.62-i686: WARNINGS
linux-2.6.17.14-i686: WARNINGS
linux-2.6.18.8-i686: WARNINGS
linux-2.6.19.7-i686: WARNINGS
linux-2.6.20.21-i686: WARNINGS
linux-2.6.21.7-i686: WARNINGS
linux-2.6.16.62-x86_64: WARNINGS
linux-2.6.17.14-x86_64: WARNINGS
linux-2.6.18.8-x86_64: WARNINGS
linux-2.6.19.7-x86_64: WARNINGS
linux-2.6.20.21-x86_64: WARNINGS
linux-2.6.21.7-x86_64: WARNINGS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Thursday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Thursday.tar.bz2

The V4L-DVB specification failed to build, but the last compiled spec is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
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 7/8] V4L/DVB: Teach drivers/media/IR/ir-raw-event.c to use durations

2010-04-08 Thread Mauro Carvalho Chehab
From: David Härdeman da...@hardeman.nu

drivers/media/IR/ir-raw-event.c is currently written with the assumption
that all raw hardware will generate events only on state change (i.e.
when a pulse or space starts).

However, some hardware (like mceusb, probably the most popular IR receiver
out there) only generates duration data (and that data is buffered so using
any kind of timing on the data is futile).

Furthermore, using signed int's to represent pulse/space durations is a
well-known approach when writing ir decoders.

With this patch:

- s64 int's are used to represent pulse/space durations in ns

- a workqueue is used to decode the ir protocols outside of interrupt context

- #defines are added to make decoders clearer

- decoder reset is implemented by passing a zero duration to the kfifo queue
  and decoders are updated accordingly

Signed-off-by: David Härdeman da...@hardeman.nu
Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

diff --git a/drivers/media/IR/ir-nec-decoder.c 
b/drivers/media/IR/ir-nec-decoder.c
index 48a86cc..5085f90 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -13,15 +13,16 @@
  */
 
 #include media/ir-core.h
+#include linux/bitrev.h
 
 #define NEC_NBITS  32
-#define NEC_UNIT   559979 /* ns */
-#define NEC_HEADER_MARK(16 * NEC_UNIT)
-#define NEC_HEADER_SPACE   (8 * NEC_UNIT)
-#define NEC_REPEAT_SPACE   (4 * NEC_UNIT)
-#define NEC_MARK   (NEC_UNIT)
-#define NEC_0_SPACE(NEC_UNIT)
-#define NEC_1_SPACE(3 * NEC_UNIT)
+#define NEC_UNIT   562500  /* ns */
+#define NEC_HEADER_PULSE   PULSE(16)
+#define NEC_HEADER_SPACE   SPACE(8)
+#define NEC_REPEAT_SPACE   SPACE(4)
+#define NEC_BIT_PULSE  PULSE(1)
+#define NEC_BIT_0_SPACESPACE(1)
+#define NEC_BIT_1_SPACESPACE(3)
 
 /* Used to register nec_decoder clients */
 static LIST_HEAD(decoder_list);
@@ -29,21 +30,13 @@ DEFINE_SPINLOCK(decoder_lock);
 
 enum nec_state {
STATE_INACTIVE,
-   STATE_HEADER_MARK,
STATE_HEADER_SPACE,
-   STATE_MARK,
-   STATE_SPACE,
-   STATE_TRAILER_MARK,
+   STATE_BIT_PULSE,
+   STATE_BIT_SPACE,
+   STATE_TRAILER_PULSE,
STATE_TRAILER_SPACE,
 };
 
-struct nec_code {
-   u8  address;
-   u8  not_address;
-   u8  command;
-   u8  not_command;
-};
-
 struct decoder_data {
struct list_headlist;
struct ir_input_dev *ir_dev;
@@ -51,7 +44,7 @@ struct decoder_data {
 
/* State machine control */
enum nec_state  state;
-   struct nec_code nec_code;
+   u32 nec_bits;
unsignedcount;
 };
 
@@ -62,7 +55,6 @@ struct decoder_data {
  *
  * Returns the struct decoder_data that corresponds to a device
  */
-
 static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
 {
struct decoder_data *data = NULL;
@@ -123,20 +115,20 @@ static struct attribute_group decoder_attribute_group = {
.attrs  = decoder_attributes,
 };
 
-
 /**
  * ir_nec_decode() - Decode one NEC pulse or space
  * @input_dev: the struct input_dev descriptor of the device
- * @ev:event array with type/duration of pulse/space
+ * @duration:  duration in ns of pulse/space
  *
  * This function returns -EINVAL if the pulse violates the state machine
  */
-static int ir_nec_decode(struct input_dev *input_dev,
-struct ir_raw_event *ev)
+static int ir_nec_decode(struct input_dev *input_dev, s64 duration)
 {
struct decoder_data *data;
struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-   int bit, last_bit;
+   int u;
+   u32 scancode;
+   u8 address, not_address, command, not_command;
 
data = get_decoder_data(ir_dev);
if (!data)
@@ -145,151 +137,108 @@ static int ir_nec_decode(struct input_dev *input_dev,
if (!data-enabled)
return 0;
 
-   /* Except for the initial event, what matters is the previous bit */
-   bit = (ev-type  IR_PULSE) ? 1 : 0;
-
-   last_bit = !bit;
-
-   /* Discards spurious space last_bits when inactive */
-
-   /* Very long delays are considered as start events */
-   if (ev-delta.tv_nsec  NEC_HEADER_MARK + NEC_HEADER_SPACE - NEC_UNIT / 
2)
+   if (IS_RESET(duration)) {
data-state = STATE_INACTIVE;
+   return 0;
+   }
 
-   if (ev-type  IR_START_EVENT)
-   data-state = STATE_INACTIVE;
+   u = TO_UNITS(duration, NEC_UNIT);
+   if (DURATION(u) == 0)
+   goto out;
+
+   IR_dprintk(2, NEC decode started at state %d (%i units, %ius)\n,
+  data-state, u, TO_US(duration));
 
switch (data-state) {
+
case STATE_INACTIVE:
-   if (!bit)   /* PULSE marks the start event */
-  

[PATCH 6/8] V4L/DVB: ir-core: fix gcc warning noise

2010-04-08 Thread Mauro Carvalho Chehab
drivers/media/IR/ir-sysfs.c: In function ‘store_protocol’:
drivers/media/IR/ir-sysfs.c:93: warning: suggest parentheses around assignment 
used as truth value

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index 9d132d0..17d4341 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -90,7 +90,7 @@ static ssize_t store_protocol(struct device *d,
unsigned long flags;
char *buf;
 
-   while (buf = strsep((char **) data,  \n)) {
+   while ((buf = strsep((char **) data,  \n)) != NULL) {
if (!strcasecmp(buf, rc-5) || !strcasecmp(buf, rc5))
ir_type |= IR_TYPE_RC5;
if (!strcasecmp(buf, pd) || !strcasecmp(buf, 
pulse-distance))
-- 
1.6.6.1


--
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 5/8] V4L/DVB: ir-core: properly present the supported and current protocols

2010-04-08 Thread Mauro Carvalho Chehab
Hardware decoders have a more limited set of decoders than software ones.
In general, they support just one protocol at a given time, but allow
changing between a few options.

Rename the previous badly named current_protocol as just protocol,
meaning the current protocol(s) accepted by the driver, and
add a support_protocols to represent the entire universe of supported
protocols by that specific hardware.

As commented on http://lwn.net/Articles/378884/, the one file, one value
rule doesn't fit nor does make much sense for bitmap or enum values. So, the
supported_protocols will enum all supported protocols, and the protocol
will present all active protocols.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index efde912..9d132d0 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -55,13 +55,13 @@ static ssize_t show_protocol(struct device *d,
if (ir_type == IR_TYPE_UNKNOWN)
s = Unknown;
else if (ir_type == IR_TYPE_RC5)
-   s = RC-5;
+   s = rc-5;
else if (ir_type == IR_TYPE_PD)
-   s = Pulse/distance;
+   s = pulse-distance;
else if (ir_type == IR_TYPE_NEC)
-   s = NEC;
+   s = nec;
else
-   s = Other;
+   s = other;
 
return sprintf(buf, %s\n, s);
 }
@@ -85,23 +85,22 @@ static ssize_t store_protocol(struct device *d,
  size_t len)
 {
struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-   u64 ir_type = IR_TYPE_UNKNOWN;
+   u64 ir_type = 0;
int rc = -EINVAL;
unsigned long flags;
char *buf;
 
-   buf = strsep((char **) data, \n);
+   while (buf = strsep((char **) data,  \n)) {
+   if (!strcasecmp(buf, rc-5) || !strcasecmp(buf, rc5))
+   ir_type |= IR_TYPE_RC5;
+   if (!strcasecmp(buf, pd) || !strcasecmp(buf, 
pulse-distance))
+   ir_type |= IR_TYPE_PD;
+   if (!strcasecmp(buf, nec))
+   ir_type |= IR_TYPE_NEC;
+   }
 
-   if (!strcasecmp(buf, rc-5) || !strcasecmp(buf, rc5))
-   ir_type = IR_TYPE_RC5;
-   else if (!strcasecmp(buf, pd))
-   ir_type = IR_TYPE_PD;
-   else if (!strcasecmp(buf, nec))
-   ir_type = IR_TYPE_NEC;
-
-   if (ir_type == IR_TYPE_UNKNOWN) {
-   IR_dprintk(1, Error setting protocol to %lld\n,
-  (long long)ir_type);
+   if (!ir_type) {
+   IR_dprintk(1, Unknown protocol\n);
return -EINVAL;
}
 
@@ -119,12 +118,34 @@ static ssize_t store_protocol(struct device *d,
ir_dev-rc_tab.ir_type = ir_type;
spin_unlock_irqrestore(ir_dev-rc_tab.lock, flags);
 
-   IR_dprintk(1, Current protocol is %lld\n,
+   IR_dprintk(1, Current protocol(s) is(are) %lld\n,
   (long long)ir_type);
 
return len;
 }
 
+static ssize_t show_supported_protocols(struct device *d,
+struct device_attribute *mattr, char *buf)
+{
+   char *orgbuf = buf;
+   struct ir_input_dev *ir_dev = dev_get_drvdata(d);
+
+   /* FIXME: doesn't support multiple protocols at the same time */
+   if (ir_dev-props-allowed_protos == IR_TYPE_UNKNOWN)
+   buf += sprintf(buf, unknown );
+   if (ir_dev-props-allowed_protos  IR_TYPE_RC5)
+   buf += sprintf(buf, rc-5 );
+   if (ir_dev-props-allowed_protos  IR_TYPE_PD)
+   buf += sprintf(buf, pulse-distance );
+   if (ir_dev-props-allowed_protos  IR_TYPE_NEC)
+   buf += sprintf(buf, nec );
+   if (buf == orgbuf)
+   buf += sprintf(buf, other );
+
+   buf += sprintf(buf - 1, \n);
+
+   return buf - orgbuf;
+}
 
 #define ADD_HOTPLUG_VAR(fmt, val...)   \
do {\
@@ -148,11 +169,15 @@ static int ir_dev_uevent(struct device *device, struct 
kobj_uevent_env *env)
 /*
  * Static device attribute struct with the sysfs attributes for IR's
  */
-static DEVICE_ATTR(current_protocol, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(protocol, S_IRUGO | S_IWUSR,
   show_protocol, store_protocol);
 
+static DEVICE_ATTR(supported_protocols, S_IRUGO | S_IWUSR,
+  show_supported_protocols, NULL);
+
 static struct attribute *ir_hw_dev_attrs[] = {
-   dev_attr_current_protocol.attr,
+   dev_attr_protocol.attr,
+   dev_attr_supported_protocols.attr,
NULL,
 };
 
-- 
1.6.6.1


--
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 1/8] V4L/DVB: em28xx: fix a regression caused by the rc-map changes

2010-04-08 Thread Mauro Carvalho Chehab
The patch that adds the rc-map changes didn't take into account that an
a table with IR_TYPE_UNKNOWN would make change_protocol to return -EINVAL.

As this function is fundamental to initialize some data, including a
callback to the getkey function, this caused the driver to stop working,
hanging the machine most of the times.

The fix were simply to add a handler for the IR type, but, to avoid further
issues, explicitly call change_protocol and handle the error before
initializing the IR. Also, let input_dev to start/stop IR handling,
after the opening of the input device.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

diff --git a/drivers/media/video/em28xx/em28xx-input.c 
b/drivers/media/video/em28xx/em28xx-input.c
index 3200f48..dffd026 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -361,14 +361,20 @@ static void em28xx_ir_work(struct work_struct *work)
schedule_delayed_work(ir-work, msecs_to_jiffies(ir-polling));
 }
 
-static void em28xx_ir_start(struct em28xx_IR *ir)
+static int em28xx_ir_start(void *priv)
 {
+   struct em28xx_IR *ir = priv;
+
INIT_DELAYED_WORK(ir-work, em28xx_ir_work);
schedule_delayed_work(ir-work, 0);
+
+   return 0;
 }
 
-static void em28xx_ir_stop(struct em28xx_IR *ir)
+static void em28xx_ir_stop(void *priv)
 {
+   struct em28xx_IR *ir = priv;
+
cancel_delayed_work_sync(ir-work);
 }
 
@@ -388,7 +394,7 @@ int em28xx_ir_change_protocol(void *priv, u64 ir_type)
dev-board.xclk = ~EM28XX_XCLK_IR_RC5_MODE;
ir_config = EM2874_IR_NEC;
ir-full_code = 1;
-   } else
+   } else if (ir_type != IR_TYPE_UNKNOWN)
rc = -EINVAL;
 
em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev-board.xclk,
@@ -441,6 +447,13 @@ int em28xx_ir_init(struct em28xx *dev)
ir-props.allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC;
ir-props.priv = ir;
ir-props.change_protocol = em28xx_ir_change_protocol;
+   ir-props.open = em28xx_ir_start;
+   ir-props.close = em28xx_ir_stop;
+
+   /* By default, keep protocol field untouched */
+   err = em28xx_ir_change_protocol(ir, IR_TYPE_UNKNOWN);
+   if (err)
+   goto err_out_free;
 
/* This is how often we ask the chip for IR information */
ir-polling = 100; /* ms */
@@ -467,7 +480,6 @@ int em28xx_ir_init(struct em28xx *dev)
input_dev-dev.parent = dev-udev-dev;
 
 
-   em28xx_ir_start(ir);
 
/* all done */
err = ir_input_register(ir-input, dev-board.ir_codes,
@@ -477,7 +489,6 @@ int em28xx_ir_init(struct em28xx *dev)
 
return 0;
  err_out_stop:
-   em28xx_ir_stop(ir);
dev-ir = NULL;
  err_out_free:
kfree(ir);
-- 
1.6.6.1


--
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 2/8] V4L/DVB: ir: Make sure that the spinlocks are properly initialized

2010-04-08 Thread Mauro Carvalho Chehab
Some spinlocks are not properly initialized on ir core:

[  471.714132] BUG: spinlock bad magic on CPU#0, modprobe/1899
[  471.719838]  lock: f92a08ac, .magic: , .owner: none/-1, 
.owner_cpu: 0
[  471.727301] Pid: 1899, comm: modprobe Not tainted 2.6.33 #36
[  471.733062] Call Trace:
[  471.735537]  [c1498793] ? printk+0x1d/0x22
[  471.739866]  [c12694e3] spin_bug+0xa3/0xf0
[  471.744224]  [c126962d] do_raw_spin_lock+0x7d/0x160
[  471.749364]  [f92a01ff] ? ir_rc5_register+0x6f/0xf0 [ir_rc5_decoder]

So, use static initialization for the static spinlocks, instead of the
dynamic ones (currently used), as proposed by David Härdeman on one
of his RFC patches.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

diff --git a/drivers/media/IR/ir-nec-decoder.c 
b/drivers/media/IR/ir-nec-decoder.c
index 9d1ada9..48a86cc 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -25,7 +25,7 @@
 
 /* Used to register nec_decoder clients */
 static LIST_HEAD(decoder_list);
-static spinlock_t decoder_lock;
+DEFINE_SPINLOCK(decoder_lock);
 
 enum nec_state {
STATE_INACTIVE,
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index 57990a3..4ba7074 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -21,7 +21,7 @@
 
 /* Used to handle IR raw handler extensions */
 static LIST_HEAD(ir_raw_handler_list);
-static spinlock_t ir_raw_handler_lock;
+DEFINE_SPINLOCK(ir_raw_handler_lock);
 
 /**
  * RUN_DECODER()   - runs an operation on all IR decoders
@@ -205,8 +205,6 @@ static void init_decoders(struct work_struct *work)
 
 void ir_raw_init(void)
 {
-   spin_lock_init(ir_raw_handler_lock);
-
 #ifdef MODULE
INIT_WORK(wq_load, init_decoders);
schedule_work(wq_load);
diff --git a/drivers/media/IR/ir-rc5-decoder.c 
b/drivers/media/IR/ir-rc5-decoder.c
index a62277b..b8a33ae 100644
--- a/drivers/media/IR/ir-rc5-decoder.c
+++ b/drivers/media/IR/ir-rc5-decoder.c
@@ -29,7 +29,7 @@ static unsigned int ir_rc5_remote_gap = 88;
 
 /* Used to register rc5_decoder clients */
 static LIST_HEAD(decoder_list);
-static spinlock_t decoder_lock;
+DEFINE_SPINLOCK(decoder_lock);
 
 enum rc5_state {
STATE_INACTIVE,
diff --git a/drivers/media/IR/rc-map.c b/drivers/media/IR/rc-map.c
index 2f6201c..38b3489 100644
--- a/drivers/media/IR/rc-map.c
+++ b/drivers/media/IR/rc-map.c
@@ -17,8 +17,7 @@
 
 /* Used to handle IR raw handler extensions */
 static LIST_HEAD(rc_map_list);
-static spinlock_t rc_map_lock;
-
+DEFINE_SPINLOCK(rc_map_lock);
 
 static struct rc_keymap *seek_rc_map(const char *name)
 {
-- 
1.6.6.1


--
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 3/8] V4L/DVB: rename sysfs remote controller devices from rcrcv to rc

2010-04-08 Thread Mauro Carvalho Chehab
From: David Härdeman da...@hardeman.nu

When the remote controller class is anyway being renamed from ir to rc
this would be a good time to also rename the devices from rcrcvX to rcX.

I know we haven't reached any agreement on whether transmission will
eventually be handled by the same device, but this change will at
least make the device name non-receive-specific which will make it
possible in the future (and if a different approach is finally
agreed upon, the device name still works).

Signed-off-by: David Härdeman da...@hardeman.nu
Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index 0b05c7b..e177140 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -39,7 +39,7 @@ static struct class ir_input_class = {
  * @buf:   a pointer to the output buffer
  *
  * This routine is a callback routine for input read the IR protocol type.
- * it is trigged by reading /sys/class/rc/rcrcv?/current_protocol.
+ * it is trigged by reading /sys/class/rc/rc?/current_protocol.
  * It returns the protocol name, as understood by the driver.
  */
 static ssize_t show_protocol(struct device *d,
@@ -74,7 +74,7 @@ static ssize_t show_protocol(struct device *d,
  * @len:   length of the input buffer
  *
  * This routine is a callback routine for changing the IR protocol type.
- * it is trigged by reading /sys/class/rc/rcrcv?/current_protocol.
+ * it is trigged by reading /sys/class/rc/rc?/current_protocol.
  * It changes the IR the protocol name, if the IR type is recognized
  * by the driver.
  * If an unknown protocol name is used, returns -EINVAL.
@@ -171,7 +171,7 @@ static struct device_type ir_dev_type = {
 };
 
 /**
- * ir_register_class() - creates the sysfs for /sys/class/rc/rcrcv?
+ * ir_register_class() - creates the sysfs for /sys/class/rc/rc?
  * @input_dev: the struct input_dev descriptor of the device
  *
  * This routine is used to register the syfs code for IR class
@@ -191,7 +191,7 @@ int ir_register_class(struct input_dev *input_dev)
ir_dev-dev.type = ir_dev_type;
ir_dev-dev.class = ir_input_class;
ir_dev-dev.parent = input_dev-dev.parent;
-   dev_set_name(ir_dev-dev, rcrcv%d, devno);
+   dev_set_name(ir_dev-dev, rc%d, devno);
dev_set_drvdata(ir_dev-dev, ir_dev);
rc = device_register(ir_dev-dev);
if (rc)
@@ -222,7 +222,7 @@ int ir_register_class(struct input_dev *input_dev)
 
 /**
  * ir_unregister_class() - removes the sysfs for sysfs for
- */sys/class/rc/rcrcv?
+ */sys/class/rc/rc?
  * @input_dev: the struct input_dev descriptor of the device
  *
  * This routine is used to unregister the syfs code for IR class
-- 
1.6.6.1


--
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 0/8] ir-core improvements

2010-04-08 Thread Mauro Carvalho Chehab
Yet another series of ir-core improvements.

This series contain two fixes, plus those improvements:

1) sysfs: better define the behaviour for in-hardware and in-software raw
   decoders: different types require different functionalities;

2) sysfs: rename Remote Controllers as rc0, rc1, ...
   this is better than rcrcv0, rcrcv1, ..., because some devices have
   also RC transmitters, and they may share some functionality with
   the receiver. So, a receiver and a transmitter will be later be
   differenciated via the associated device nodes;

3) Rework ir-raw-event to support a third type of decoders: in-hardware
   samplers, with in-software decoders. In this case, the IR events
   (duration and type) are provided by the hardware, and the protocol
   decode is done in software.

Those are the patches from this series:

David Härdeman (2):
  V4L/DVB: rename sysfs remote controller devices from rcrcv to rc
  V4L/DVB: Teach drivers/media/IR/ir-raw-event.c to use durations

Mauro Carvalho Chehab (6):
  V4L/DVB: em28xx: fix a regression caused by the rc-map changes
  V4L/DVB: ir: Make sure that the spinlocks are properly initialized
  V4L/DVB: ir-core: Distinguish sysfs attributes for in-hardware and raw 
decoders
  V4L/DVB: ir-core: properly present the supported and current protocols
  V4L/DVB: ir-core: fix gcc warning noise
  V4L/DVB: ir-core: move subsystem internal calls to ir-core-priv.h

 drivers/media/IR/ir-core-priv.h |  112 +
 drivers/media/IR/ir-functions.c |1 +
 drivers/media/IR/ir-keytable.c  |   19 ++-
 drivers/media/IR/ir-nec-decoder.c   |  241 +++
 drivers/media/IR/ir-raw-event.c |  161 ++
 drivers/media/IR/ir-rc5-decoder.c   |  154 +-
 drivers/media/IR/ir-sysfs.c |  100 
 drivers/media/IR/rc-map.c   |3 +-
 drivers/media/video/em28xx/em28xx-input.c   |   21 ++-
 drivers/media/video/saa7134/saa7134-input.c |   11 +-
 include/media/ir-core.h |   81 +++---
 11 files changed, 502 insertions(+), 402 deletions(-)
 create mode 100644 drivers/media/IR/ir-core-priv.h

--
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 4/8] V4L/DVB: ir-core: Distinguish sysfs attributes for in-hardware and raw decoders

2010-04-08 Thread Mauro Carvalho Chehab
Some devices have in-hardware Remote Controller decoder, while others
need a software decoder to get the IR code. As each software decoder
can be enabled/disabled individually, allowing multiple protocol
decoding capability.

On the other hand, hardware decoders have a limited protocol
support, often being able of decoding just one protocol each time.
So, each type needs a different set of capabilities to control the
supported protocol(s).

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c
index f509be2..67b2aa1 100644
--- a/drivers/media/IR/ir-keytable.c
+++ b/drivers/media/IR/ir-keytable.c
@@ -487,11 +487,19 @@ int __ir_input_register(struct input_dev *input_dev,
if (rc  0)
goto out_table;
 
+   if (ir_dev-props-driver_type == RC_DRIVER_IR_RAW) {
+   rc = ir_raw_event_register(input_dev);
+   if (rc  0)
+   goto out_event;
+   }
+
IR_dprintk(1, Registered input device on %s for %s remote.\n,
   driver_name, rc_tab-name);
 
return 0;
 
+out_event:
+   ir_unregister_class(input_dev);
 out_table:
kfree(ir_dev-rc_tab.scan);
 out_name:
@@ -508,22 +516,25 @@ EXPORT_SYMBOL_GPL(__ir_input_register);
 
  * This routine is used to free memory and de-register interfaces.
  */
-void ir_input_unregister(struct input_dev *dev)
+void ir_input_unregister(struct input_dev *input_dev)
 {
-   struct ir_input_dev *ir_dev = input_get_drvdata(dev);
+   struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
struct ir_scancode_table *rc_tab;
 
if (!ir_dev)
return;
 
IR_dprintk(1, Freed keycode table\n);
+
del_timer_sync(ir_dev-timer_keyup);
+   if (ir_dev-props-driver_type == RC_DRIVER_IR_RAW)
+   ir_raw_event_unregister(input_dev);
rc_tab = ir_dev-rc_tab;
rc_tab-size = 0;
kfree(rc_tab-scan);
rc_tab-scan = NULL;
 
-   ir_unregister_class(dev);
+   ir_unregister_class(input_dev);
 
kfree(ir_dev-driver_name);
kfree(ir_dev);
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index 4ba7074..5b121d8 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -82,7 +82,6 @@ int ir_raw_event_register(struct input_dev *input_dev)
 
return rc;
 }
-EXPORT_SYMBOL_GPL(ir_raw_event_register);
 
 void ir_raw_event_unregister(struct input_dev *input_dev)
 {
@@ -97,7 +96,6 @@ void ir_raw_event_unregister(struct input_dev *input_dev)
kfree(ir-raw);
ir-raw = NULL;
 }
-EXPORT_SYMBOL_GPL(ir_raw_event_unregister);
 
 int ir_raw_event_store(struct input_dev *input_dev, enum raw_event_type type)
 {
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index e177140..efde912 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -151,22 +151,26 @@ static int ir_dev_uevent(struct device *device, struct 
kobj_uevent_env *env)
 static DEVICE_ATTR(current_protocol, S_IRUGO | S_IWUSR,
   show_protocol, store_protocol);
 
-static struct attribute *ir_dev_attrs[] = {
+static struct attribute *ir_hw_dev_attrs[] = {
dev_attr_current_protocol.attr,
NULL,
 };
 
-static struct attribute_group ir_dev_attr_grp = {
-   .attrs  = ir_dev_attrs,
+static struct attribute_group ir_hw_dev_attr_grp = {
+   .attrs  = ir_hw_dev_attrs,
 };
 
-static const struct attribute_group *ir_dev_attr_groups[] = {
-   ir_dev_attr_grp,
+static const struct attribute_group *ir_hw_dev_attr_groups[] = {
+   ir_hw_dev_attr_grp,
NULL
 };
 
-static struct device_type ir_dev_type = {
-   .groups = ir_dev_attr_groups,
+static struct device_type rc_dev_type = {
+   .groups = ir_hw_dev_attr_groups,
+   .uevent = ir_dev_uevent,
+};
+
+static struct device_type ir_raw_dev_type = {
.uevent = ir_dev_uevent,
 };
 
@@ -180,7 +184,6 @@ int ir_register_class(struct input_dev *input_dev)
 {
int rc;
const char *path;
-
struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
int devno = find_first_zero_bit(ir_core_dev_number,
IRRCV_NUM_DEVICES);
@@ -188,7 +191,11 @@ int ir_register_class(struct input_dev *input_dev)
if (unlikely(devno  0))
return devno;
 
-   ir_dev-dev.type = ir_dev_type;
+   if (ir_dev-props-driver_type == RC_DRIVER_SCANCODE)
+   ir_dev-dev.type = rc_dev_type;
+   else
+   ir_dev-dev.type = ir_raw_dev_type;
+
ir_dev-dev.class = ir_input_class;
ir_dev-dev.parent = input_dev-dev.parent;
dev_set_name(ir_dev-dev, rc%d, devno);
diff --git a/drivers/media/video/saa7134/saa7134-input.c 
b/drivers/media/video/saa7134/saa7134-input.c
index 7e95dc8..dc4faaf 100644
--- 

RE: [PATCH 06/16] V4L/DVB: vpif: remove unused #include linux/version.h

2010-04-08 Thread Karicheri, Muralidharan
Signed-off-by: Muralidharan Karicheri mkarich...@gmail.com

Murali Karicheri
Software Design Engineer
Texas Instruments Inc.
Germantown, MD 20874
phone: 301-407-9583
email: m-kariche...@ti.com

-Original Message-
From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
ow...@vger.kernel.org] On Behalf Of Huang Weiyi
Sent: Thursday, April 08, 2010 7:49 AM
To: mche...@redhat.com
Cc: linux-media@vger.kernel.org; Huang Weiyi
Subject: [PATCH 06/16] V4L/DVB: vpif: remove unused #include
linux/version.h

Remove unused #include linux/version.h('s) in
  drivers/media/video/davinci/vpif_capture.c
  drivers/media/video/davinci/vpif_display.c

Signed-off-by: Huang Weiyi weiyi.hu...@gmail.com
---
 drivers/media/video/davinci/vpif_capture.c |1 -
 drivers/media/video/davinci/vpif_display.c |1 -
 2 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/davinci/vpif_capture.c
b/drivers/media/video/davinci/vpif_capture.c
index 2e5a7fb..f74b551 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -33,7 +33,6 @@
 #include linux/i2c.h
 #include linux/platform_device.h
 #include linux/io.h
-#include linux/version.h
 #include linux/slab.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
diff --git a/drivers/media/video/davinci/vpif_display.c
b/drivers/media/video/davinci/vpif_display.c
index 13c3a1b..f8cd5e5 100644
--- a/drivers/media/video/davinci/vpif_display.c
+++ b/drivers/media/video/davinci/vpif_display.c
@@ -29,7 +29,6 @@
 #include linux/i2c.h
 #include linux/platform_device.h
 #include linux/io.h
-#include linux/version.h
 #include linux/slab.h

 #include asm/irq.h
--
1.6.1.3

--
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
--
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 8/8] V4L/DVB: ir-core: move subsystem internal calls to ir-core-priv.h

2010-04-08 Thread Mauro Carvalho Chehab
Mauro Carvalho Chehab wrote:
 ir-core.h has the kABI to be used by the bridge drivers, when needing to 
 register
 IR protocols and pass IR events. However, the same file also contains IR 
 subsystem
 internal calls, meant to be used inside ir-core and between ir-core and the 
 raw
 decoders.
 
 Better to move those functions to an internal header, for some reasons:
 
 1) Header will be a little more cleaner;
 
 2) It avoids the need of recompile everything (bridge/hardware drivers, etc),
just because a new decoder were added, or some other internal change were 
 needed;
 
 3) Better organize the ir-core API, splitting the functions that are internal 
 to
IR core and the ancillary drivers (decoders, lirc_dev) from the features 
 that
should be exported to IR subsystem clients.
 
 Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
 
  create mode 100644 drivers/media/IR/ir-core-priv.h

This cleanup were too aggressive:

drivers/media/dvb/ttpci/budget-ci.c: In function ‘msp430_ir_interrupt’:
drivers/media/dvb/ttpci/budget-ci.c:163: error: implicit declaration of 
function ‘ir_keydown’

We need ir_keydown() / ir_repeat() for in-hardware decoders. I'm folding it
with this patch:

diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index ab785bc..8d97d6c 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -62,8 +62,6 @@ struct ir_raw_event_ctrl {
 
 u32 ir_g_keycode_from_table(struct input_dev *input_dev,
u32 scancode);
-void ir_repeat(struct input_dev *dev);
-void ir_keydown(struct input_dev *dev, int scancode, u8 toggle);
 
 /*
  * Routines from ir-sysfs.c - Meant to be called only internally inside
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
index 40b6250..ab3bd30 100644
--- a/include/media/ir-core.h
+++ b/include/media/ir-core.h
@@ -122,6 +122,9 @@ static inline int ir_input_register(struct input_dev *dev,
 
 void ir_input_unregister(struct input_dev *input_dev);
 
+void ir_repeat(struct input_dev *dev);
+void ir_keydown(struct input_dev *dev, int scancode, u8 toggle);
+
 /* From ir-raw-event.c */
 
 void ir_raw_event_handle(struct input_dev *input_dev);



-- 

Cheers,
Mauro
--
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 3/3] Convert drivers/media/dvb/ttpci/budget-ci.c to use ir-core

2010-04-08 Thread Mauro Carvalho Chehab
da...@hardeman.nu wrote:
 This patch converts drivers/media/dvb/ttpci/budget-ci.c to use ir-core
 rather than rolling its own keydown timeout handler and reporting keys
 via drivers/media/IR/ir-functions.c.

Hmm... had you test this patch? It got me an error here:

drivers/media/dvb/ttpci/budget-ci.c: In function ‘msp430_ir_init’:
drivers/media/dvb/ttpci/budget-ci.c:228: error: implicit declaration of 
function ‘ir_input_init’
drivers/media/dvb/ttpci/budget-ci.c:228: error: ‘struct budget_ci_ir’ has no 
member named ‘state’

The fix is trivial. Just drop this line:

ir_input_init(input_dev, budget_ci-ir.state, IR_TYPE_RC5);

It shouldn't cause any troubles, since the only things this function currently 
do are:
ir-ir_type = ir_type;

if (repeat)
set_bit(EV_REP, dev-evbit);

As the repeat is inside ir-core, and the ir struct is not used anymore, this 
removal
should cause no harm.

So, I am dropping the line at the code I'm committing at v4l-dvb.git, to avoid 
bisect
breakages.

 
 Signed-off-by: David Härdeman da...@hardeman.nu
 
 
 Index: ir/drivers/media/dvb/ttpci/budget-ci.c
 ===
 --- ir.orig/drivers/media/dvb/ttpci/budget-ci.c   2010-04-02 
 16:41:15.524206900 +0200
 +++ ir/drivers/media/dvb/ttpci/budget-ci.c2010-04-02 16:48:15.668239437 
 +0200
 @@ -35,7 +35,7 @@
  #include linux/interrupt.h
  #include linux/input.h
  #include linux/spinlock.h
 -#include media/ir-common.h
 +#include media/ir-core.h
  
  #include budget.h
  
 @@ -82,12 +82,6 @@
  #define SLOTSTATUS_READY 8
  #define SLOTSTATUS_OCCUPIED  
 (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
  
 -/*
 - * Milliseconds during which a key is regarded as pressed.
 - * If an identical command arrives within this time, the timer will start 
 over.
 - */
 -#define IR_KEYPRESS_TIMEOUT  250
 -
  /* RC5 device wildcard */
  #define IR_DEVICE_ANY255
  
 @@ -104,12 +98,9 @@
  struct budget_ci_ir {
   struct input_dev *dev;
   struct tasklet_struct msp430_irq_tasklet;
 - struct timer_list timer_keyup;
   char name[72]; /* 40 + 32 for (struct saa7146_dev).name */
   char phys[32];
 - struct ir_input_state state;
   int rc5_device;
 - u32 last_raw;
   u32 ir_key;
   bool have_command;
  };
 @@ -124,18 +115,11 @@
   u8 tuner_pll_address; /* used for philips_tdm1316l configs */
  };
  
 -static void msp430_ir_keyup(unsigned long data)
 -{
 - struct budget_ci_ir *ir = (struct budget_ci_ir *) data;
 - ir_input_nokey(ir-dev, ir-state);
 -}
 -
  static void msp430_ir_interrupt(unsigned long data)
  {
   struct budget_ci *budget_ci = (struct budget_ci *) data;
   struct input_dev *dev = budget_ci-ir.dev;
   u32 command = ttpci_budget_debiread(budget_ci-budget, DEBINOSWAP, 
 DEBIADDR_IR, 2, 1, 0)  8;
 - u32 raw;
  
   /*
* The msp430 chip can generate two different bytes, command and device
 @@ -171,20 +155,12 @@
   return;
   budget_ci-ir.have_command = false;
  
 + /* FIXME: We should generate complete scancodes with device info */
   if (budget_ci-ir.rc5_device != IR_DEVICE_ANY 
   budget_ci-ir.rc5_device != (command  0x1f))
   return;
  
 - /* Is this a repeated key sequence? (same device, command, toggle) */
 - raw = budget_ci-ir.ir_key | (command  8);
 - if (budget_ci-ir.last_raw != raw || 
 !timer_pending(budget_ci-ir.timer_keyup)) {
 - ir_input_nokey(dev, budget_ci-ir.state);
 - ir_input_keydown(dev, budget_ci-ir.state,
 -  budget_ci-ir.ir_key);
 - budget_ci-ir.last_raw = raw;
 - }
 -
 - mod_timer(budget_ci-ir.timer_keyup, jiffies + 
 msecs_to_jiffies(IR_KEYPRESS_TIMEOUT));
 + ir_keydown(dev, budget_ci-ir.ir_key, (command  0x20) ? 1 : 0);
  }
  
  static int msp430_ir_init(struct budget_ci *budget_ci)
 @@ -251,11 +227,6 @@
  
   ir_input_init(input_dev, budget_ci-ir.state, IR_TYPE_RC5);
  
 - /* initialise the key-up timeout handler */
 - init_timer(budget_ci-ir.timer_keyup);
 - budget_ci-ir.timer_keyup.function = msp430_ir_keyup;
 - budget_ci-ir.timer_keyup.data = (unsigned long) budget_ci-ir;
 - budget_ci-ir.last_raw = 0x; /* An impossible value */
   error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
   if (error) {
   printk(KERN_ERR budget_ci: could not init driver for IR device 
 (code %d)\n, error);
 @@ -284,9 +255,6 @@
   saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
   tasklet_kill(budget_ci-ir.msp430_irq_tasklet);
  
 - del_timer_sync(dev-timer);
 - ir_input_nokey(dev, budget_ci-ir.state);
 -
   ir_input_unregister(dev);
  }
  
 
 --
 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  

[PATCH 2/4] Add RC5x support to ir-core

2010-04-08 Thread David Härdeman
This patch adds RC5x support to drivers/media/IR/ir-rc5-decoder.c

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/IR/ir-rc5-decoder.c |   78 -
 1 files changed, 59 insertions(+), 19 deletions(-)

diff --git a/drivers/media/IR/ir-rc5-decoder.c 
b/drivers/media/IR/ir-rc5-decoder.c
index 59bcaa9..c970ab2 100644
--- a/drivers/media/IR/ir-rc5-decoder.c
+++ b/drivers/media/IR/ir-rc5-decoder.c
@@ -1,4 +1,4 @@
-/* ir-rc5-decoder.c - handle RC-5 IR Pulse/Space protocol
+/* ir-rc5-decoder.c - handle RC5(x) IR Pulse/Space protocol
  *
  * Copyright (C) 2010 by Mauro Carvalho Chehab mche...@redhat.com
  *
@@ -13,15 +13,19 @@
  */
 
 /*
- * This code only handles 14 bits RC-5 protocols. There are other variants
- * that use a different number of bits. This is currently unsupported
- * It considers a carrier of 36 kHz, with a total of 14 bits, where
+ * This code handles 14 bits RC5 protocols and 20 bits RC5x protocols.
+ * There are other variants that use a different number of bits.
+ * This is currently unsupported.
+ * It considers a carrier of 36 kHz, with a total of 14/20 bits, where
  * the first two bits are start bits, and a third one is a filing bit
  */
 
 #include ir-core-priv.h
 
 #define RC5_NBITS  14
+#define RC5X_NBITS 20
+#define CHECK_RC5X_NBITS   8
+#define RC5X_SPACE SPACE(4)
 #define RC5_UNIT   88 /* ns */
 
 /* Used to register rc5_decoder clients */
@@ -32,6 +36,7 @@ enum rc5_state {
STATE_INACTIVE,
STATE_BIT_START,
STATE_BIT_END,
+   STATE_CHECK_RC5X,
STATE_FINISHED,
 };
 
@@ -45,6 +50,7 @@ struct decoder_data {
u32 rc5_bits;
int last_unit;
unsignedcount;
+   unsignedwanted_bits;
 };
 
 
@@ -126,7 +132,7 @@ static int ir_rc5_decode(struct input_dev *input_dev, s64 
duration)
 {
struct decoder_data *data;
struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-   u8 command, system, toggle;
+   u8 toggle;
u32 scancode;
int u;
 
@@ -147,7 +153,7 @@ static int ir_rc5_decode(struct input_dev *input_dev, s64 
duration)
goto out;
 
 again:
-   IR_dprintk(2, RC5 decode started at state %i (%i units, %ius)\n,
+   IR_dprintk(2, RC5(x) decode started at state %i (%i units, %ius)\n,
   data-state, u, TO_US(duration));
 
if (DURATION(u) == 0  data-state != STATE_FINISHED)
@@ -159,6 +165,8 @@ again:
if (IS_PULSE(u)) {
data-state = STATE_BIT_START;
data-count = 1;
+   /* We just need enough bits to get to STATE_CHECK_RC5X 
*/
+   data-wanted_bits = RC5X_NBITS;
DECREASE_DURATION(u, 1);
goto again;
}
@@ -176,7 +184,7 @@ again:
 * If the last bit is zero, a space will merge
 * with the silence after the command.
 */
-   if (IS_PULSE(u)  data-count == RC5_NBITS) {
+   if (IS_PULSE(u)  data-count == data-wanted_bits) {
data-state = STATE_FINISHED;
goto again;
}
@@ -188,8 +196,10 @@ again:
 
case STATE_BIT_END:
if (IS_TRANSITION(u, data-last_unit)) {
-   if (data-count == RC5_NBITS)
+   if (data-count == data-wanted_bits)
data-state = STATE_FINISHED;
+   else if (data-count == CHECK_RC5X_NBITS)
+   data-state = STATE_CHECK_RC5X;
else
data-state = STATE_BIT_START;
 
@@ -198,22 +208,52 @@ again:
}
break;
 
+   case STATE_CHECK_RC5X:
+   if (IS_SPACE(u)  DURATION(u) = DURATION(RC5X_SPACE)) {
+   /* RC5X */
+   data-wanted_bits = RC5X_NBITS;
+   DECREASE_DURATION(u, DURATION(RC5X_SPACE));
+   } else {
+   /* RC5 */
+   data-wanted_bits = RC5_NBITS;
+   }
+   data-state = STATE_BIT_START;
+   goto again;
+
case STATE_FINISHED:
-   command  = (data-rc5_bits  0x0003F)  0;
-   system   = (data-rc5_bits  0x007C0)  6;
-   toggle   = (data-rc5_bits  0x00800) ? 1 : 0;
-   command += (data-rc5_bits  0x01000) ? 0 : 0x40;
-   scancode = system  8 | command;
-
-   IR_dprintk(1, RC5 scancode 0x%04x (toggle: %u)\n,
-  scancode, toggle);
+   if (data-wanted_bits == RC5X_NBITS) {
+   /* RC5X */
+   

[PATCH 3/4] Add NECx support to ir-core

2010-04-08 Thread David Härdeman
This patch adds NECx support to drivers/media/IR/ir-nec-decoder.c

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/IR/ir-nec-decoder.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/media/IR/ir-nec-decoder.c 
b/drivers/media/IR/ir-nec-decoder.c
index f22d1af..d128c19 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -18,6 +18,7 @@
 #define NEC_NBITS  32
 #define NEC_UNIT   562500  /* ns */
 #define NEC_HEADER_PULSE   PULSE(16)
+#define NECX_HEADER_PULSE  PULSE(8) /* Less common NEC variant */
 #define NEC_HEADER_SPACE   SPACE(8)
 #define NEC_REPEAT_SPACE   SPACE(4)
 #define NEC_BIT_PULSE  PULSE(1)
@@ -152,7 +153,7 @@ static int ir_nec_decode(struct input_dev *input_dev, s64 
duration)
switch (data-state) {
 
case STATE_INACTIVE:
-   if (u == NEC_HEADER_PULSE) {
+   if (u == NEC_HEADER_PULSE || u == NECX_HEADER_PULSE) {
data-count = 0;
data-state = STATE_HEADER_SPACE;
}

--
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 4/4] Add RC6 support to ir-core

2010-04-08 Thread David Härdeman
This patch adds an RC6 decoder (modes 0 and 6A) to ir-core.

Signed-off-by: David Härdeman da...@hardeman.nu
---
 drivers/media/IR/Kconfig  |9 +
 drivers/media/IR/Makefile |1 
 drivers/media/IR/ir-core-priv.h   |7 +
 drivers/media/IR/ir-raw-event.c   |1 
 drivers/media/IR/ir-rc6-decoder.c |  412 +
 drivers/media/IR/ir-sysfs.c   |2 
 include/media/rc-map.h|1 
 7 files changed, 433 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/IR/ir-rc6-decoder.c

diff --git a/drivers/media/IR/Kconfig b/drivers/media/IR/Kconfig
index ba81bda..28d336d 100644
--- a/drivers/media/IR/Kconfig
+++ b/drivers/media/IR/Kconfig
@@ -27,3 +27,12 @@ config IR_RC5_DECODER
---help---
   Enable this option if you have IR with RC-5 protocol, and
   if the IR is decoded in software
+
+config IR_RC6_DECODER
+   tristate Enable IR raw decoder for the RC6 protocol
+   depends on IR_CORE
+   default y
+
+   ---help---
+  Enable this option if you have an infrared remote control which
+  uses the RC6 protocol, and you need software decoding support.
diff --git a/drivers/media/IR/Makefile b/drivers/media/IR/Makefile
index 62e12d5..792d9ca 100644
--- a/drivers/media/IR/Makefile
+++ b/drivers/media/IR/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_IR_CORE) += ir-core.o
 obj-$(CONFIG_VIDEO_IR) += ir-common.o
 obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o
 obj-$(CONFIG_IR_RC5_DECODER) += ir-rc5-decoder.o
+obj-$(CONFIG_IR_RC6_DECODER) += ir-rc6-decoder.o
diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index ab785bc..853ec80 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -109,4 +109,11 @@ void ir_raw_init(void);
 #define load_rc5_decode()  0
 #endif
 
+/* from ir-rc6-decoder.c */
+#ifdef CONFIG_IR_RC5_DECODER_MODULE
+#define load_rc6_decode()  request_module(ir-rc6-decoder)
+#else
+#define load_rc6_decode()  0
+#endif
+
 #endif /* _IR_RAW_EVENT */
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index 2efc051..ef0f231 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -224,6 +224,7 @@ static void init_decoders(struct work_struct *work)
 
load_nec_decode();
load_rc5_decode();
+   load_rc6_decode();
 
/* If needed, we may later add some init code. In this case,
   it is needed to change the CONFIG_MODULE test at ir-core.h
diff --git a/drivers/media/IR/ir-rc6-decoder.c 
b/drivers/media/IR/ir-rc6-decoder.c
new file mode 100644
index 000..ccc5be2
--- /dev/null
+++ b/drivers/media/IR/ir-rc6-decoder.c
@@ -0,0 +1,412 @@
+/* ir-rc6-decoder.c - A decoder for the RC6 IR protocol
+ *
+ * Copyright (C) 2010 by David Härdeman da...@hardeman.nu
+ *
+ * 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 version 2 of the License.
+ *
+ * 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.
+ */
+
+#include ir-core-priv.h
+
+/*
+ * This decoder currently supports:
+ * RC6-0-16(standard toggle bit in header)
+ * RC6-6A-24   (no toggle bit)
+ * RC6-6A-32   (MCE version with toggle bit in body)
+ */
+
+#define RC6_UNIT   44  /* us */
+#define RC6_HEADER_NBITS   4   /* not including toggle bit */
+#define RC6_0_NBITS16
+#define RC6_6A_SMALL_NBITS 24
+#define RC6_6A_LARGE_NBITS 32
+#define RC6_PREFIX_PULSE   PULSE(6)
+#define RC6_PREFIX_SPACE   SPACE(2)
+#define RC6_MODE_MASK  0x07/* for the header bits */
+#define RC6_STARTBIT_MASK  0x08/* for the header bits */
+#define RC6_6A_MCE_TOGGLE_MASK 0x8000  /* for the body bits */
+
+/* Used to register rc6_decoder clients */
+static LIST_HEAD(decoder_list);
+static DEFINE_SPINLOCK(decoder_lock);
+
+enum rc6_mode {
+   RC6_MODE_0,
+   RC6_MODE_6A,
+   RC6_MODE_UNKNOWN,
+};
+
+enum rc6_state {
+   STATE_INACTIVE,
+   STATE_PREFIX_SPACE,
+   STATE_HEADER_BIT_START,
+   STATE_HEADER_BIT_END,
+   STATE_TOGGLE_START,
+   STATE_TOGGLE_END,
+   STATE_BODY_BIT_START,
+   STATE_BODY_BIT_END,
+   STATE_FINISHED,
+};
+
+struct decoder_data {
+   struct list_headlist;
+   struct ir_input_dev *ir_dev;
+   int enabled:1;
+
+   /* State machine control */
+   enum rc6_state  state;
+   u8  header;
+   u32 body;
+   int last_unit;
+   booltoggle;
+   unsignedcount;
+   unsigned

Re: [patch 3/3] Convert drivers/media/dvb/ttpci/budget-ci.c to use ir-core

2010-04-08 Thread David Härdeman

On Thu, Apr 08, 2010 at 06:59:30PM -0300, Mauro Carvalho Chehab wrote:

da...@hardeman.nu wrote:

This patch converts drivers/media/dvb/ttpci/budget-ci.c to use ir-core
rather than rolling its own keydown timeout handler and reporting keys
via drivers/media/IR/ir-functions.c.


Hmm... had you test this patch? It got me an error here:


Sorry, I must have sent you the wrong one :)


drivers/media/dvb/ttpci/budget-ci.c: In function ‘msp430_ir_init’:
drivers/media/dvb/ttpci/budget-ci.c:228: error: implicit declaration of 
function ‘ir_input_init’
drivers/media/dvb/ttpci/budget-ci.c:228: error: ‘struct budget_ci_ir’ has no 
member named ‘state’

The fix is trivial. Just drop this line:

   ir_input_init(input_dev, budget_ci-ir.state, IR_TYPE_RC5);

It shouldn't cause any troubles, since the only things this function currently 
do are:
   ir-ir_type = ir_type;

   if (repeat)
   set_bit(EV_REP, dev-evbit);

As the repeat is inside ir-core, and the ir struct is not used anymore, this 
removal
should cause no harm.

So, I am dropping the line at the code I'm committing at v4l-dvb.git, to avoid 
bisect
breakages.


You're entirely correct, that line should have been dropped (I even sent 
the same thing as part of my latest patch series before I read this 
mail, but if you can fixup the original patch that'd be even better).



--
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 1/4] Fix the drivers/media/dvb/ttpci/budget-ci.c conversion to ir-core

2010-04-08 Thread Mauro Carvalho Chehab
Hi David,

David Härdeman wrote:
 When I converted drivers/media/dvb/ttpci/budget-ci.c to use ir-core
 I missed one line. This patch fixes that mistake.

I did this already (I merged with your commit, at v4l-dvb.git), to avoid 
breaking git bisect. I'll backport it to the ir.git tree after finishing
to process my lng patchwork queue. (I'll probably just create a new
branch there from v4l-dvb.git - since I've merged all ir-related patches
there already).


Cheers,
Mauro

PS.: As you can see, stgit did the right thing with inline ;)
 
 Signed-off-by: David Härdeman da...@hardeman.nu
 ---
  drivers/media/dvb/ttpci/budget-ci.c |2 --
  1 files changed, 0 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/dvb/ttpci/budget-ci.c 
 b/drivers/media/dvb/ttpci/budget-ci.c
 index 8950df1..4617143 100644
 --- a/drivers/media/dvb/ttpci/budget-ci.c
 +++ b/drivers/media/dvb/ttpci/budget-ci.c
 @@ -225,8 +225,6 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
   break;
   }
  
 - ir_input_init(input_dev, budget_ci-ir.state, IR_TYPE_RC5);
 -
   error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
   if (error) {
   printk(KERN_ERR budget_ci: could not init driver for IR device 
 (code %d)\n, error);
 


-- 

Cheers,
Mauro
--
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 3/3] Convert drivers/media/dvb/ttpci/budget-ci.c to use ir-core

2010-04-08 Thread Mauro Carvalho Chehab
David Härdeman wrote:
 On Thu, Apr 08, 2010 at 06:59:30PM -0300, Mauro Carvalho Chehab wrote:
 da...@hardeman.nu wrote:
 This patch converts drivers/media/dvb/ttpci/budget-ci.c to use ir-core
 rather than rolling its own keydown timeout handler and reporting keys
 via drivers/media/IR/ir-functions.c.

 Hmm... had you test this patch? It got me an error here:
 
 Sorry, I must have sent you the wrong one :)
 
 drivers/media/dvb/ttpci/budget-ci.c: In function ‘msp430_ir_init’:
 drivers/media/dvb/ttpci/budget-ci.c:228: error: implicit declaration
 of function ‘ir_input_init’
 drivers/media/dvb/ttpci/budget-ci.c:228: error: ‘struct budget_ci_ir’
 has no member named ‘state’

 The fix is trivial. Just drop this line:

ir_input_init(input_dev, budget_ci-ir.state, IR_TYPE_RC5);

 It shouldn't cause any troubles, since the only things this function
 currently do are:
ir-ir_type = ir_type;

if (repeat)
set_bit(EV_REP, dev-evbit);

 As the repeat is inside ir-core, and the ir struct is not used
 anymore, this removal
 should cause no harm.

 So, I am dropping the line at the code I'm committing at v4l-dvb.git,
 to avoid bisect
 breakages.
 
 You're entirely correct, that line should have been dropped (I even sent
 the same thing as part of my latest patch series before I read this
 mail, but if you can fixup the original patch that'd be even better).

While I don't care much on experimental trees, I always do a make allyesconfig
and try to compile all drivers before pushing on my master tree. This helps
to avoid some silly mistakes to go upstream ;)

-- 

Cheers,
Mauro
--
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] Fix default state Beholder H6 tuner.

2010-04-08 Thread Mauro Carvalho Chehab
Em 01-04-2010 01:33, Dmitri Belimov escreveu:
 Hi Hermann
 
 Hi Dimitry,

 Am Mittwoch, den 31.03.2010, 13:14 +1000 schrieb Dmitri Belimov:
 Hi Hermann

 Hi,

 Am Dienstag, den 30.03.2010, 16:02 +1000 schrieb Dmitri Belimov:
 Hi

 The hybrid tuner FMD1216MEX_MK3 after cold start has disabled
 IF. This tuner has internal I2C switch. This switch switch I2C
 bus between DVB-T and IF part. Default state is DVB-T. When
 module saa7134 is load it can't find IF tda9887 and disable
 analog TV mode.

 This patch set internal I2C switch of the tuner to IF by send
 special value to the tuner as for receive analog TV from low
 band. It can be usefule for other cards.

 I didn't set configure a tuner by a tuner model because this
 tuner can has different I2C address. May be we can do it later
 after discuss for more robust support a tuners.

 just as a reminder. It is the same for the FMD1216ME hybrid MK3.
 After every boot, analog mode fails with missing tda9887.

 Currently, after tuner modules are not independent anymore, one
 has to reload the saa7134 driver once.

 Relevant code in tuner.core.c.

case TUNER_PHILIPS_FMD1216ME_MK3:
buffer[0] = 0x0b;
buffer[1] = 0xdc;
buffer[2] = 0x9c;
buffer[3] = 0x60;
i2c_master_send(c, buffer, 4);
mdelay(1);
buffer[2] = 0x86;
buffer[3] = 0x54;
i2c_master_send(c, buffer, 4);
if (!dvb_attach(simple_tuner_attach, t-fe,
t-i2c-adapter, t-i2c-addr,
 t-type)) goto attach_failed;
break;

 That is good. I'll try add case TUNER_PHILIPS_FMD1216MEX_MK3 here
 and test. This is much better.

 it wont work for any what I can tell.

 We were forced into such an universal looking solution, but it was
 broken only a short time later.

 I for sure don't say that this time, late 2005, it was in anyway
 perfect, too much random on module load orders and also duplicate
 address stuff around meanwhile.

 But, however, it seems to be blocked for a global attempt within the
 current schemes too.
 
 Yes. Not worked. My patch is good for our customers right now. But when this 
 subsystem is ready we can switch
 to use it.
 
 With my best regards, Dmitry.
 

I'll apply the patch for now, but the better is to fix the 
TUNER_PHILIPS_FMD1216MEX_MK3.

Dmitri, could you please try to fix it with a more generic solution?

Thanks,
Mauro
--
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


I have a list of 788k doctors in America

2010-04-08 Thread Conklin cuttlefish
To get additional details, samples and counts for our USA contact data please
email me at this address katelyn.r...@optinlists.co.cc

we have lots of different lists in many fields and this week is the time to buy 
with lowered list prices.
  




have a look at this if you don't like to recieve these kinds of emails please 
send an email to rem...@optinlists.co.cc

configured. These fields are set to zero by default.
--
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 2/2] V4L/DVB: Use custom I2C probing function mechanism

2010-04-08 Thread Mauro Carvalho Chehab
Jean Delvare wrote:
 Hi Mauro,
 
 On Tue, 06 Apr 2010 02:34:46 -0300, Mauro Carvalho Chehab wrote:
 Jean Delvare wrote:
 On Mon, 05 Apr 2010 15:26:32 -0300, Mauro Carvalho Chehab wrote:
 Please, don't add new things at ir-common module. It basically contains the
 decoding functions for RC5 and pulse/distance, plus several IR keymaps. 
 With
 the IR rework I'm doing, this module will go away, after having all the 
 current 
 IR decoders implemented via ir-raw-input binding. 

 The keymaps were already removed from it, on my experimental tree 
 (http://git.linuxtv.org/mchehab/ir.git), and rc5 decoder is already written
 (but still needs a few fixes). 

 The new ir-core is creating an abstract way to deal with Remote 
 Controllers,
 meant to be used not only by IR's, but also for other types of RC, like, 
 bluetooth and USB HID. It will also export a raw event interface, for use
 with lirc. As this is the core of the RC subsystem, a i2c-specific binding
 method also doesn't seem to belong there. SO, IMO, the better place is to 
 add 
 it as a static inline function at ir-kbd-i2c.h.
 Ever tried to pass the address of an inline function as another
 function's parameter? :)
 :) Never tried... maybe gcc would to the hard thing, de-inlining it ;)

 Well, we need to put this code somewhere. Where are the other probing
 codes? Probably the better is to put them together.
 
 There are no other probing functions yet, this is the first one. I have
 added the mechanism to i2c-core for these very IR chips.
 
 Putting all probe functions together would mean moving them to
 i2c-core. This wasn't my original intent, but after all, it makes some
 sense. Would you be happy with the following?

It seems fine for me. As you're touching on i2c core and on other drivers
on this series, I think that the better is if you could apply it on your
tree.

For both patches 1 and 2:

Acked-by: Mauro Carvalho Chehab mche...@redhat.com

 
 * * * * *
 
 From: Jean Delvare kh...@linux-fr.org
 Subject: V4L/DVB: Use custom I2C probing function mechanism
 
 Now that i2c-core offers the possibility to provide custom probing
 function for I2C devices, let's make use of it.
 
 Signed-off-by: Jean Delvare kh...@linux-fr.org
 ---
  drivers/i2c/i2c-core.c|7 +++
  drivers/media/video/cx23885/cx23885-i2c.c |   15 ---
  drivers/media/video/cx88/cx88-i2c.c   |   19 ---
  include/linux/i2c.h   |3 +++
  4 files changed, 18 insertions(+), 26 deletions(-)
 
 --- linux-2.6.34-rc3.orig/drivers/media/video/cx23885/cx23885-i2c.c   
 2010-04-06 11:31:20.0 +0200
 +++ linux-2.6.34-rc3/drivers/media/video/cx23885/cx23885-i2c.c
 2010-04-06 12:28:09.0 +0200
 @@ -365,17 +365,10 @@ int cx23885_i2c_register(struct cx23885_
  
   memset(info, 0, sizeof(struct i2c_board_info));
   strlcpy(info.type, ir_video, I2C_NAME_SIZE);
 - /*
 -  * We can't call i2c_new_probed_device() because it uses
 -  * quick writes for probing and the IR receiver device only
 -  * replies to reads.
 -  */
 - if (i2c_smbus_xfer(bus-i2c_adap, addr_list[0], 0,
 -I2C_SMBUS_READ, 0, I2C_SMBUS_QUICK,
 -NULL) = 0) {
 - info.addr = addr_list[0];
 - i2c_new_device(bus-i2c_adap, info);
 - }
 + /* Use quick read command for probe, some IR chips don't
 +  * support writes */
 + i2c_new_probed_device(bus-i2c_adap, info, addr_list,
 +   i2c_probe_func_quick_read);
   }
  
   return bus-i2c_rc;
 --- linux-2.6.34-rc3.orig/drivers/media/video/cx88/cx88-i2c.c 2010-04-06 
 11:31:20.0 +0200
 +++ linux-2.6.34-rc3/drivers/media/video/cx88/cx88-i2c.c  2010-04-06 
 12:28:06.0 +0200
 @@ -188,24 +188,13 @@ int cx88_i2c_init(struct cx88_core *core
   0x18, 0x6b, 0x71,
   I2C_CLIENT_END
   };
 - const unsigned short *addrp;
  
   memset(info, 0, sizeof(struct i2c_board_info));
   strlcpy(info.type, ir_video, I2C_NAME_SIZE);
 - /*
 -  * We can't call i2c_new_probed_device() because it uses
 -  * quick writes for probing and at least some R receiver
 -  * devices only reply to reads.
 -  */
 - for (addrp = addr_list; *addrp != I2C_CLIENT_END; addrp++) {
 - if (i2c_smbus_xfer(core-i2c_adap, *addrp, 0,
 -I2C_SMBUS_READ, 0,
 -I2C_SMBUS_QUICK, NULL) = 0) {
 - info.addr = *addrp;
 - i2c_new_device(core-i2c_adap, info);
 - break;
 - }
 - }
 + 

Re: [PATCH] cx88: implement sharpness control

2010-04-08 Thread Mauro Carvalho Chehab
istva...@mailbox.hu wrote:
 This patch adds support for V4L2_CID_SHARPNESS by changing the luma peak
 filter and notch filter. It can be set in the range 0 to 9, with 0 being
 the original and default mode.
 One minor problem is that other code that sets the registers being used
 (for example when switching TV channels) could reset the control to the
 default. This could be avoided by making changes so that the bits used
 to implement this control are not overwritten.
 
 Signed-off-by: Istvan Varga istv...@users.sourceforge.net
 
 + case V4L2_CID_SHARPNESS:
 + /* use 4xFsc or square pixel notch filter */
 + cx_andor(MO_HTOTAL, 0x1800, (ctl-value  1)  11);
 + /* 0b000, 0b100, 0b101, 0b110, or 0b111 */
 + value = (ctl-value  2 ? 0 : (((ctl-value + 6)  0x0E)  6));
 + /* needs to be set for both fields */
 + cx_andor(MO_FILTER_EVEN, mask, value);
 + break;

You're not adjusting the sharpness. Instead, you're changing the vertical tap 
filter,
and just for the even frames, plus the notch filter.
Tricky, and you're probably affecting the sharpness, but on an indirect and 
non-linear
way, as you're adjusting different measures.

This doesn't seem right, at least on my eyes. If this is really needed, it would
be better to break it into two controls (one for the notch filter and another 
for the
vertical tap filter).

Also, the side effect is not good: if you're using those bits, your code 
should assure
that no other part of the driver will touch on the used bits, and that the 
device will
be initialized with the default standard.

-- 

Cheers,
Mauro
--
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