Re: sparse: ARRAY_SIZE and sparse array initialization

2014-03-29 Thread Christopher Li
On Fri, Mar 28, 2014 at 3:50 AM, Hans Verkuil  wrote:
> Is there any chance that the three issues I reported will be fixed? If not,
> then I'll work around it in the kernel code.
>

Most likely it is a sparse issue. Can you generate a minimal stand alone
test case that expose this bug? I try to simplify it as following, but
it does not
reproduce the error.


#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))

static const char *v4l2_type_names[] = {
[1]= "mmap",
[9] = "userptr",
[2] = "overlay",
[3] = "dmabuf",
};

#define prt_names(a, arr) (((unsigned)(a)) < ARRAY_SIZE(arr) ? arr[a]
: "unknown")


extern void prt(const char *name);

static void v4l_print_requestbuffers(const void *arg, int write_only)
{
const struct v4l2_requestbuffers *p = arg;

prt(prt_names(3, v4l2_type_names));
}


If you have the test case, you are welcome to submit a patch to
add the test case.

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: [PATCH] [media] uvcvideo: Fix clock param realtime setting

2014-03-29 Thread Olivier Langlois
Hi Laurent,

> > Yes. ffmpeg uses wall clock time to create timestamps for audio packets from
> > ALSA device.
> 
> OK. I suppose I shouldn't drop support for the realtime clock like I wanted 
> to 
> then :-)
>  
> > There is a bug in ffmpeg describing problems to synchronize audio and
> > the video from a v4l2 webcam.
> > 
> > https://trac.ffmpeg.org/ticket/692
> > 
> > To workaround this issue, ffmpeg devs added a switch to convert back
> > monotonic to realtime. From ffmpeg/libavdevice/v4l2.c:
> > 
> >   -ts.D set type of timestamps for
> > grabbed frames (from 0 to 2) (default 0)
> >  default  .D use timestamps from the kernel
> >  abs  .D use absolute timestamps (wall
> > clock)
> >  mono2abs .D force conversion from monotonic
> > to absolute timestamps
> > 
> > If the v4l2 driver is able to send realtime ts, it is easier synchronize
> > in userspace if all inputs use the same clock.
> 
> That might be a stupid question, but shouldn't ALSA use the monotonic clock 
> instead ?
> 
I think that I have that answer why ffmpeg use realtime clock for ALSA
data. In fact ffmpeg uses realtime clock for every data coming from
capture devices and the purpose is to be able to seek into the recorded
stream by using the date where the recording occured. Same principle
than a camera recording dates when pictures are taken.

now a tougher question is whether or not it is up to the driver to
provide these realtime ts.

I'm looking forward your verdict.


--
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: media_tree daily build: ERRORS

2014-03-29 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Sun Mar 30 04:00:13 CEST 2014
git branch: test
git hash:   3ec40dcfb413214b2874aec858870502b61c2202
gcc version:i686-linux-gcc (GCC) 4.8.2
sparse version: v0.5.0
host hardware:  x86_64
host os:3.13-7.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: ERRORS
linux-git-m32r: OK
linux-git-mips: ERRORS
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: ERRORS
linux-2.6.31.14-i686: ERRORS
linux-2.6.32.27-i686: ERRORS
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: ERRORS
linux-2.6.35.9-i686: ERRORS
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9.2-i686: ERRORS
linux-3.10.1-i686: ERRORS
linux-3.11.1-i686: ERRORS
linux-3.12-i686: ERRORS
linux-3.13-i686: ERRORS
linux-3.14-rc1-i686: ERRORS
linux-2.6.31.14-x86_64: ERRORS
linux-2.6.32.27-x86_64: ERRORS
linux-2.6.33.7-x86_64: ERRORS
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9.2-x86_64: ERRORS
linux-3.10.1-x86_64: ERRORS
linux-3.11.1-x86_64: ERRORS
linux-3.12-x86_64: ERRORS
linux-3.13-x86_64: ERRORS
linux-3.14-rc1-x86_64: ERRORS
apps: OK
spec-git: OK
sparse version: v0.5.0
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build 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


Half price off all watches

2014-03-29 Thread Linux c programming
Look rich without paying the price with one of our quality branded watches
http://www.princessbag.co.jp/eufqour.php


--
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: FireDTV / w_scan / no data from NIT(actual)

2014-03-29 Thread Podium B.V.

Dear Steve,

I am already using the "-F" and the "-t 3" option...
So a longer time waiting is not possible.

-F   use long filter timeout
-t N   tuning timeout
  1 = fastest [default]
  2 = medium
  3 = slowest

And there are "NIT(actual) table" on the frequencies.
My result should be very much like: http://www.dtvmonitor.com/nl/ziggo-noord

But I also search more what my problem could be and I discovered that
most examples say:

using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'

and i only get:

using '/dev/dvb/adapter0/frontend0'

But I guess demuxing is necessary to get the "NIT(actual) table", isn't it ?






On 29-03-14 14:44, Steven Toth wrote:
>> Only is goes already wrong with the init scan I only get: "Info: 
no data

>> from NIT(actual)"
> I suspect either their isn't a NIT(actual) table on your frequency, or
> the tool isn't waiting long enough for the NIT table to arrive.
>
> - Steve






--
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/3] rc-main: Revert generic scancode filtering support

2014-03-29 Thread David Härdeman
On Wed, Mar 26, 2014 at 09:08:31PM +, James Hogan wrote:
>This reverts commit b8c7d915087c ([media] rc-main: add generic scancode
>filtering), and removes certain parts of commit 6bea25af147f ([media]
>rc-main: automatically refresh filter on protocol change) where generic
>filtering is taken into account when refreshing filters on a protocol
>change, but that code cannot be reached any longer since the filter mask
>will always be zero if the s_filter callback is NULL.

I think it'd be a more complete fix to make sure the sysfs files aren't
even there if there's no hw support. See the patchset I've just
posted...

Regards,
David

--
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] rc-core: do not change 32bit NEC scancode format for now

2014-03-29 Thread David Härdeman
On Fri, Mar 28, 2014 at 11:17:09PM +, James Hogan wrote:
>On Friday 28 March 2014 01:08:56 David Härdeman wrote:
>> drivers/media/usb/dvb-usb-v2/az6007.c
>> drivers/media/usb/dvb-usb-v2/af9035.c
>> drivers/media/usb/dvb-usb-v2/rtl28xxu.c
>> drivers/media/usb/dvb-usb-v2/af9015.c
>> drivers/media/usb/em28xx/em28xx-input.c
>
>Note, it appears none of these do any bit reversing for the 32bit case 
>compared to 16/24 bit, so they're already different to the NEC32 scancode 
>encoding that the raw nec decoder and tivo keymap were using, which used a 
>different bitorder (!!) between the 32-bit and the 24/16-bit cases.

I know, and none of those drivers have an in-kernel NEC32 keymap, so if
anyone is using them in that manner...it's with a homebrew keymap.

>> I'd rather show you my complete proposal first before doing something
>> radical with your driver. But it was a good reminder that I need to keep
>> the NEC32 parsing in your driver in mind as well.
>
>Okay no problem. I had assumed you were aiming for a short term fix to prevent 
>the encoding change hitting mainline or an actual release (v3.15).

I am aiming for a fix within that time frame...but I hope that it can be
more than a short term one :)

Patches are on their way right now...

Regards,
David

--
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 00/11] rc-core: My current patch queue

2014-03-29 Thread David Härdeman
This is my current patch queue, I've resent the whole queue since there
are some patches that conflict with patches that James have sent to the
list.

The first three patches should not be controversial since they only do
cleanups/documentation (already posted to the list).

The next three patches are mostly for James to review.

Then there are three more patches to make sure NECX is handled in a
consitent manner (I've already asked for feedback for some of these).

The last two patches are only RFCs at this stage, but they show how
I think we should solve the NEC scancode issue in the long run (by
treating NEC16, NECX, NEC32 as NEC32 simply...and converting as
necessary...also a new ioctl to make the protocol explicit, which
has value for all protocols).

---

David Härdeman (11):
  bt8xx: fixup RC5 decoding
  rc-core: improve ir-kbd-i2c get_key functions
  rc-core: document the protocol type
  rc-core: do not change 32bit NEC scancode format for now
  rc-core: split dev->s_filter
  rc-core: remove generic scancode filter
  dib0700: NEC scancode cleanup
  lmedm04: NEC scancode cleanup
  saa7134: NEC scancode fix
  [RFC] rc-core: use the full 32 bits for NEC scancodes
  [RFC] rc-core: don't throw away protocol information


 drivers/media/i2c/ir-kbd-i2c.c  |   91 ---
 drivers/media/pci/bt8xx/bttv-input.c|   78 +++---
 drivers/media/pci/bt8xx/bttvp.h |2 
 drivers/media/pci/cx88/cx88-input.c |   34 ++-
 drivers/media/pci/dm1105/dm1105.c   |3 
 drivers/media/pci/ivtv/ivtv-i2c.c   |9 -
 drivers/media/pci/saa7134/saa7134-input.c   |   86 ---
 drivers/media/pci/ttpci/budget-ci.c |8 -
 drivers/media/rc/img-ir/img-ir-hw.c |   23 +-
 drivers/media/rc/img-ir/img-ir-hw.h |3 
 drivers/media/rc/img-ir/img-ir-jvc.c|4 
 drivers/media/rc/img-ir/img-ir-nec.c|   80 +-
 drivers/media/rc/img-ir/img-ir-sanyo.c  |4 
 drivers/media/rc/img-ir/img-ir-sharp.c  |4 
 drivers/media/rc/img-ir/img-ir-sony.c   |   12 +
 drivers/media/rc/ir-jvc-decoder.c   |2 
 drivers/media/rc/ir-nec-decoder.c   |   33 ---
 drivers/media/rc/ir-rc5-decoder.c   |5 
 drivers/media/rc/ir-rc5-sz-decoder.c|2 
 drivers/media/rc/ir-rc6-decoder.c   |   37 ++-
 drivers/media/rc/ir-sanyo-decoder.c |2 
 drivers/media/rc/ir-sharp-decoder.c |2 
 drivers/media/rc/ir-sony-decoder.c  |6 
 drivers/media/rc/keymaps/rc-behold.c|   68 +++--
 drivers/media/rc/keymaps/rc-lme2510.c   |   80 +++---
 drivers/media/rc/keymaps/rc-nebula.c|  112 -
 drivers/media/rc/keymaps/rc-tivo.c  |   95 ---
 drivers/media/rc/rc-main.c  |  344 ---
 drivers/media/usb/cx231xx/cx231xx-input.c   |   20 +-
 drivers/media/usb/dvb-usb-v2/af9015.c   |   22 --
 drivers/media/usb/dvb-usb-v2/af9035.c   |   16 -
 drivers/media/usb/dvb-usb-v2/anysee.c   |3 
 drivers/media/usb/dvb-usb-v2/az6007.c   |   17 -
 drivers/media/usb/dvb-usb-v2/lmedm04.c  |   25 +-
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c |   18 -
 drivers/media/usb/dvb-usb/dib0700_core.c|   39 +--
 drivers/media/usb/dvb-usb/dib0700_devices.c |   24 +-
 drivers/media/usb/dvb-usb/dw2102.c  |7 -
 drivers/media/usb/dvb-usb/m920x.c   |2 
 drivers/media/usb/dvb-usb/pctv452e.c|8 -
 drivers/media/usb/dvb-usb/ttusb2.c  |6 
 drivers/media/usb/em28xx/em28xx-input.c |   98 
 drivers/media/usb/tm6000/tm6000-input.c |   51 +++-
 include/media/ir-kbd-i2c.h  |6 
 include/media/rc-core.h |   34 ++-
 include/media/rc-map.h  |   26 ++
 46 files changed, 930 insertions(+), 721 deletions(-)

-- 
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 11/11] [RFC] rc-core: don't throw away protocol information

2014-03-29 Thread David Härdeman
Setting and getting keycodes in the input subsystem used to be done via
the EVIOC[GS]KEYCODE ioctl and "unsigned int[2]" (one int for scancode
and one for the keycode).

The interface has now been extended to use the EVIOC[GS]KEYCODE_V2 ioctl
which uses the following struct:

struct input_keymap_entry {
__u8  flags;
__u8  len;
__u16 index;
__u32 keycode;
__u8  scancode[32];
};

(scancode can of course be even bigger, thanks to the len member).

This patch changes how the "input_keymap_entry" struct is interpreted
by rc-core by casting it to "rc_keymap_entry":

struct rc_scancode {
__u16 protocol;
__u16 reserved[3];
__u64 scancode;
}

struct rc_keymap_entry {
__u8  flags;
__u8  len;
__u16 index;
__u32 keycode;
union {
struct rc_scancode rc;
__u8 raw[32];
};
};

The u64 scancode member is large enough for all current protocols and it
would be possible to extend it in the future should it be necessary for
some exotic protocol.

The main advantage with this change is that the protocol is made explicit,
which means that we're not throwing away data (the protocol type) and that
it'll be easier to support multiple protocols with one decoder (think rc5
and rc5-streamzap).

Heuristics are also added to hopefully do the right thing with older
ioctls in order to preserve backwards compatibility.

Further patches will also add the ability to communicate the protocol to
userspace.

Signed-off-by: David Härdeman 
---
 drivers/media/rc/rc-main.c |  184 
 include/media/rc-core.h|   20 +
 include/media/rc-map.h |8 +-
 3 files changed, 155 insertions(+), 57 deletions(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 59bc44f..cd7fd27 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -102,7 +102,7 @@ EXPORT_SYMBOL_GPL(rc_map_unregister);
 
 
 static struct rc_map_table empty[] = {
-   { 0x2a, KEY_COFFEE },
+   { RC_TYPE_OTHER, 0x2a, KEY_COFFEE },
 };
 
 static struct rc_map_list empty_map = {
@@ -118,7 +118,6 @@ static struct rc_map_list empty_map = {
  * ir_create_table() - initializes a scancode table
  * @rc_map:the rc_map to initialize
  * @name:  name to assign to the table
- * @rc_type:   ir type to assign to the new table
  * @size:  initial size of the table
  * @return:zero on success or a negative error code
  *
@@ -126,10 +125,9 @@ static struct rc_map_list empty_map = {
  * memory to hold at least the specified number of elements.
  */
 static int ir_create_table(struct rc_map *rc_map,
-  const char *name, u64 rc_type, size_t size)
+  const char *name, size_t size)
 {
rc_map->name = name;
-   rc_map->rc_type = rc_type;
rc_map->alloc = roundup_pow_of_two(size * sizeof(struct rc_map_table));
rc_map->size = rc_map->alloc / sizeof(struct rc_map_table);
rc_map->scan = kmalloc(rc_map->alloc, GFP_KERNEL);
@@ -224,16 +222,20 @@ static unsigned int ir_update_mapping(struct rc_dev *dev,
 
/* Did the user wish to remove the mapping? */
if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN) {
-   IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",
-  index, rc_map->scan[index].scancode);
+   IR_dprintk(1, "#%d: Deleting proto 0x%04x, scan 0x%08llx\n",
+  index, rc_map->scan[index].protocol,
+  (unsigned long long)rc_map->scan[index].scancode);
rc_map->len--;
memmove(&rc_map->scan[index], &rc_map->scan[index+ 1],
(rc_map->len - index) * sizeof(struct rc_map_table));
} else {
-   IR_dprintk(1, "#%d: %s scan 0x%04x with key 0x%04x\n",
+   IR_dprintk(1, "#%d: %s proto 0x%04x, scan 0x%08llx "
+  "with key 0x%04x\n",
   index,
   old_keycode == KEY_RESERVED ? "New" : "Replacing",
-  rc_map->scan[index].scancode, new_keycode);
+  rc_map->scan[index].protocol,
+  (unsigned long long)rc_map->scan[index].scancode,
+  new_keycode);
rc_map->scan[index].keycode = new_keycode;
__set_bit(new_keycode, dev->input_dev->keybit);
}
@@ -260,9 +262,9 @@ static unsigned int ir_update_mapping(struct rc_dev *dev,
  * ir_establish_scancode() - set a keycode in the scancode->keycode table
  * @dev:   the struct rc_dev device descriptor
  * @rc_map:scancode table to be searched
- * @scancode:  the desired scancode
- * @resize:controls whether we allowed to resize the table to
- * accommodate not yet present scancodes
+ * @entry: the entry to be added to the table
+

[PATCH 05/11] rc-core: split dev->s_filter

2014-03-29 Thread David Härdeman
Overloading dev->s_filter to do two different functions (set wakeup filters
and generic hardware filters) makes it impossible to tell what the
hardware actually supports, so create a separate dev->s_wakeup_filter and
make the distinction explicit.

Signed-off-by: David Härdeman 
---
 drivers/media/rc/img-ir/img-ir-hw.c |   15 ++-
 drivers/media/rc/rc-main.c  |   31 +++
 include/media/rc-core.h |6 --
 3 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/drivers/media/rc/img-ir/img-ir-hw.c 
b/drivers/media/rc/img-ir/img-ir-hw.c
index aec79f7..871a9b3 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -504,6 +504,18 @@ unlock:
return ret;
 }
 
+static int img_ir_set_normal_filter(struct rc_dev *dev,
+   struct rc_scancode_filter *sc_filter)
+{
+   return img_ir_set_filter(dev, RC_FILTER_NORMAL, sc_filter); 
+}
+
+static int img_ir_set_wakeup_filter(struct rc_dev *dev,
+   struct rc_scancode_filter *sc_filter)
+{
+   return img_ir_set_filter(dev, RC_FILTER_WAKEUP, sc_filter);
+}
+
 /**
  * img_ir_set_decoder() - Set the current decoder.
  * @priv:  IR private data.
@@ -988,7 +1000,8 @@ int img_ir_probe_hw(struct img_ir_priv *priv)
rdev->map_name = RC_MAP_EMPTY;
rc_set_allowed_protocols(rdev, img_ir_allowed_protos(priv));
rdev->input_name = "IMG Infrared Decoder";
-   rdev->s_filter = img_ir_set_filter;
+   rdev->s_filter = img_ir_set_normal_filter;
+   rdev->s_wakeup_filter = img_ir_set_wakeup_filter;
 
/* Register hardware decoder */
error = rc_register_device(rdev);
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index c0bfd50..ba955ac 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -929,6 +929,7 @@ static ssize_t store_protocols(struct device *device,
int rc, i, count = 0;
ssize_t ret;
int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
+   int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter 
*filter);
struct rc_scancode_filter local_filter, *filter;
 
/* Device is being removed */
@@ -1013,24 +1014,27 @@ static ssize_t store_protocols(struct device *device,
 * Fall back to clearing the filter.
 */
filter = &dev->scancode_filters[fattr->type];
+   set_filter = (fattr->type == RC_FILTER_NORMAL)
+   ? dev->s_filter : dev->s_wakeup_filter;
+
if (old_type != type && filter->mask) {
local_filter = *filter;
if (!type) {
/* no protocol => clear filter */
ret = -1;
-   } else if (!dev->s_filter) {
+   } else if (!set_filter) {
/* generic filtering => accept any filter */
ret = 0;
} else {
/* hardware filtering => try setting, otherwise clear */
-   ret = dev->s_filter(dev, fattr->type, &local_filter);
+   ret = set_filter(dev, &local_filter);
}
if (ret < 0) {
/* clear the filter */
local_filter.data = 0;
local_filter.mask = 0;
-   if (dev->s_filter)
-   dev->s_filter(dev, fattr->type, &local_filter);
+   if (set_filter)
+   set_filter(dev, &local_filter);
}
 
/* commit the new filter */
@@ -1112,6 +1116,7 @@ static ssize_t store_filter(struct device *device,
struct rc_scancode_filter local_filter, *filter;
int ret;
unsigned long val;
+   int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter 
*filter);
 
/* Device is being removed */
if (!dev)
@@ -1121,9 +1126,11 @@ static ssize_t store_filter(struct device *device,
if (ret < 0)
return ret;
 
-   /* Scancode filter not supported (but still accept 0) */
-   if (!dev->s_filter && fattr->type != RC_FILTER_NORMAL)
-   return val ? -EINVAL : count;
+   /* Can the scancode filter be set? */
+   set_filter = (fattr->type == RC_FILTER_NORMAL)
+   ? dev->s_filter : dev->s_wakeup_filter;
+   if (!set_filter)
+   return -EINVAL;
 
mutex_lock(&dev->lock);
 
@@ -1134,16 +1141,16 @@ static ssize_t store_filter(struct device *device,
local_filter.mask = val;
else
local_filter.data = val;
+
if (!dev->enabled_protocols[fattr->type] && local_filter.mask) {
/* refuse to set a filter unless a protocol is enabled */
ret = -EINVAL;
goto unlock;
}
-   if (dev->s_filter) {
- 

[PATCH 01/11] bt8xx: fixup RC5 decoding

2014-03-29 Thread David Härdeman
The bt8xx driver does RC5 decoding for Nebula digi hardware, but includes
some pointless limitations (both start bits must be one, the
device/address/system must be 0x00). Remove those limitations and update
the keymap to use the full RC5 scancode (fortunately the 0x00 address
means that this is perfectly backwards compatible).

Signed-off-by: David Härdeman 
---
 drivers/media/pci/bt8xx/bttv-input.c |   62 ++-
 drivers/media/pci/bt8xx/bttvp.h  |2 -
 drivers/media/rc/keymaps/rc-nebula.c |  112 +-
 3 files changed, 88 insertions(+), 88 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-input.c 
b/drivers/media/pci/bt8xx/bttv-input.c
index 5930bce..ffc0ee1 100644
--- a/drivers/media/pci/bt8xx/bttv-input.c
+++ b/drivers/media/pci/bt8xx/bttv-input.c
@@ -154,10 +154,10 @@ static void bttv_input_timer(unsigned long data)
  * testing.
  */
 
-#define RC5_START(x)   (((x) >> 12) & 3)
-#define RC5_TOGGLE(x)  (((x) >> 11) & 1)
-#define RC5_ADDR(x)(((x) >> 6) & 31)
-#define RC5_INSTR(x)   ((x) & 63)
+#define RC5_START(x)   (((x) >> 12) & 0x03)
+#define RC5_TOGGLE(x)  (((x) >> 11) & 0x01)
+#define RC5_ADDR(x)(((x) >> 6)  & 0x1f)
+#define RC5_INSTR(x)   (((x) >> 0)  & 0x3f)
 
 /* decode raw bit pattern to RC5 code */
 static u32 bttv_rc5_decode(unsigned int code)
@@ -195,8 +195,8 @@ static void bttv_rc5_timer_end(unsigned long data)
 {
struct bttv_ir *ir = (struct bttv_ir *)data;
struct timeval tv;
-   u32 gap;
-   u32 rc5 = 0;
+   u32 gap, rc5, scancode;
+   u8 toggle, command, system;
 
/* get time */
do_gettimeofday(&tv);
@@ -221,26 +221,29 @@ static void bttv_rc5_timer_end(unsigned long data)
if (ir->last_bit < 20) {
/* ignore spurious codes (caused by light/other remotes) */
dprintk("short code: %x\n", ir->code);
-   } else {
-   ir->code = (ir->code << ir->shift_by) | 1;
-   rc5 = bttv_rc5_decode(ir->code);
-
-   /* two start bits? */
-   if (RC5_START(rc5) != ir->start) {
-   pr_info(DEVNAME ":"
-  " rc5 start bits invalid: %u\n", RC5_START(rc5));
-
-   /* right address? */
-   } else if (RC5_ADDR(rc5) == ir->addr) {
-   u32 toggle = RC5_TOGGLE(rc5);
-   u32 instr = RC5_INSTR(rc5);
-
-   /* Good code */
-   rc_keydown(ir->dev, instr, toggle);
-   dprintk("instruction %x, toggle %x\n",
-   instr, toggle);
-   }
+   return;
}
+
+   ir->code = (ir->code << ir->shift_by) | 1;
+   rc5 = bttv_rc5_decode(ir->code);
+
+   toggle = RC5_TOGGLE(rc5);
+   system = RC5_ADDR(rc5);
+   command = RC5_INSTR(rc5);
+
+   switch (RC5_START(rc5)) {
+   case 0x3:
+   break;
+   case 0x2:
+   command += 0x40;
+   break;
+   default:
+   return;
+   }
+
+   scancode = system << 8 | command;
+   rc_keydown(ir->dev, scancode, toggle);
+   dprintk("scancode %x, toggle %x\n", scancode, toggle);
 }
 
 static int bttv_rc5_irq(struct bttv *btv)
@@ -310,8 +313,6 @@ static void bttv_ir_start(struct bttv *btv, struct bttv_ir 
*ir)
/* set timer_end for code completion */
setup_timer(&ir->timer, bttv_rc5_timer_end, (unsigned long)ir);
ir->shift_by = 1;
-   ir->start = 3;
-   ir->addr = 0x0;
ir->rc5_remote_gap = ir_rc5_remote_gap;
}
 }
@@ -490,8 +491,8 @@ int bttv_input_init(struct bttv *btv)
ir->polling  = 50; // ms
break;
case BTTV_BOARD_NEBULA_DIGITV:
-   ir_codes = RC_MAP_NEBULA;
-   ir->rc5_gpio = true;
+   ir_codes = RC_MAP_NEBULA;
+   ir->rc5_gpio = true;
break;
case BTTV_BOARD_MACHTV_MAGICTV:
ir_codes = RC_MAP_APAC_VIEWCOMP;
@@ -514,7 +515,8 @@ int bttv_input_init(struct bttv *btv)
   ir->mask_keycode);
break;
}
-   if (NULL == ir_codes) {
+
+   if (!ir_codes) {
dprintk("Ooops: IR config error [card=%d]\n", btv->c.type);
err = -ENODEV;
goto err_out_free;
diff --git a/drivers/media/pci/bt8xx/bttvp.h b/drivers/media/pci/bt8xx/bttvp.h
index 6eefb59..9fe19488 100644
--- a/drivers/media/pci/bt8xx/bttvp.h
+++ b/drivers/media/pci/bt8xx/bttvp.h
@@ -133,8 +133,6 @@ struct bttv_ir {
u32 polling;
u32 last_gpio;
int shift_by;
-   int start; // What should RC5_START() be
-   int addr; // What RC5_ADDR() should be.
  

[PATCH 08/11] lmedm04: NEC scancode cleanup

2014-03-29 Thread David Härdeman
I am assuming (given the ^ 0xff) that the hardware sends inverted bytes.
And that the reason ibuf[5] does not need ^ 0xff is that it already is
the inverted command (i.e. ibuf[5] == ~ibuf[4]).

To put it differently:

ibuf[2] = ~addr = not_addr;
ibuf[3] = ~not_addr = addr;
ibuf[4] = ~cmd  = not_cmd;
ibuf[5] = ~not_cmd  = cmd;

And the scancode can then be understood as:

addr << 16 | not_addr << 8 | cmd

Except for when addr = 0x00 in which case the scancode is simply NEC16:

0x00 << 8 | cmd

Signed-off-by: David Härdeman 
---
 drivers/media/rc/keymaps/rc-lme2510.c  |   80 
 drivers/media/usb/dvb-usb-v2/lmedm04.c |   28 ---
 2 files changed, 59 insertions(+), 49 deletions(-)

diff --git a/drivers/media/rc/keymaps/rc-lme2510.c 
b/drivers/media/rc/keymaps/rc-lme2510.c
index 51f18bb..76e9265 100644
--- a/drivers/media/rc/keymaps/rc-lme2510.c
+++ b/drivers/media/rc/keymaps/rc-lme2510.c
@@ -42,47 +42,47 @@ static struct rc_map_table lme2510_rc[] = {
{ 0x10ed07, KEY_EPG },
{ 0x10ed01, KEY_STOP },
/* Type 2 - 20 buttons */
-   { 0xbf15, KEY_0 },
-   { 0xbf08, KEY_1 },
-   { 0xbf09, KEY_2 },
-   { 0xbf0a, KEY_3 },
-   { 0xbf0c, KEY_4 },
-   { 0xbf0d, KEY_5 },
-   { 0xbf0e, KEY_6 },
-   { 0xbf10, KEY_7 },
-   { 0xbf11, KEY_8 },
-   { 0xbf12, KEY_9 },
-   { 0xbf00, KEY_POWER },
-   { 0xbf04, KEY_MEDIA_REPEAT}, /* Recall */
-   { 0xbf1a, KEY_PAUSE }, /* Timeshift */
-   { 0xbf02, KEY_VOLUMEUP }, /* 2 x -/+ Keys not marked */
-   { 0xbf06, KEY_VOLUMEDOWN }, /* Volume defined as right hand*/
-   { 0xbf01, KEY_CHANNELUP },
-   { 0xbf05, KEY_CHANNELDOWN },
-   { 0xbf14, KEY_ZOOM },
-   { 0xbf18, KEY_RECORD },
-   { 0xbf16, KEY_STOP },
+   { 0x00bf15, KEY_0 },
+   { 0x00bf08, KEY_1 },
+   { 0x00bf09, KEY_2 },
+   { 0x00bf0a, KEY_3 },
+   { 0x00bf0c, KEY_4 },
+   { 0x00bf0d, KEY_5 },
+   { 0x00bf0e, KEY_6 },
+   { 0x00bf10, KEY_7 },
+   { 0x00bf11, KEY_8 },
+   { 0x00bf12, KEY_9 },
+   { 0x00bf00, KEY_POWER },
+   { 0x00bf04, KEY_MEDIA_REPEAT}, /* Recall */
+   { 0x00bf1a, KEY_PAUSE }, /* Timeshift */
+   { 0x00bf02, KEY_VOLUMEUP }, /* 2 x -/+ Keys not marked */
+   { 0x00bf06, KEY_VOLUMEDOWN }, /* Volume defined as right hand*/
+   { 0x00bf01, KEY_CHANNELUP },
+   { 0x00bf05, KEY_CHANNELDOWN },
+   { 0x00bf14, KEY_ZOOM },
+   { 0x00bf18, KEY_RECORD },
+   { 0x00bf16, KEY_STOP },
/* Type 3 - 20 buttons */
-   { 0x1c, KEY_0 },
-   { 0x07, KEY_1 },
-   { 0x15, KEY_2 },
-   { 0x09, KEY_3 },
-   { 0x16, KEY_4 },
-   { 0x19, KEY_5 },
-   { 0x0d, KEY_6 },
-   { 0x0c, KEY_7 },
-   { 0x18, KEY_8 },
-   { 0x5e, KEY_9 },
-   { 0x45, KEY_POWER },
-   { 0x44, KEY_MEDIA_REPEAT}, /* Recall */
-   { 0x4a, KEY_PAUSE }, /* Timeshift */
-   { 0x47, KEY_VOLUMEUP }, /* 2 x -/+ Keys not marked */
-   { 0x43, KEY_VOLUMEDOWN }, /* Volume defined as right hand*/
-   { 0x46, KEY_CHANNELUP },
-   { 0x40, KEY_CHANNELDOWN },
-   { 0x08, KEY_ZOOM },
-   { 0x42, KEY_RECORD },
-   { 0x5a, KEY_STOP },
+   { 0x1c, KEY_0 },
+   { 0x07, KEY_1 },
+   { 0x15, KEY_2 },
+   { 0x09, KEY_3 },
+   { 0x16, KEY_4 },
+   { 0x19, KEY_5 },
+   { 0x0d, KEY_6 },
+   { 0x0c, KEY_7 },
+   { 0x18, KEY_8 },
+   { 0x5e, KEY_9 },
+   { 0x45, KEY_POWER },
+   { 0x44, KEY_MEDIA_REPEAT}, /* Recall */
+   { 0x4a, KEY_PAUSE }, /* Timeshift */
+   { 0x47, KEY_VOLUMEUP }, /* 2 x -/+ Keys not marked */
+   { 0x43, KEY_VOLUMEDOWN }, /* Volume defined as right hand*/
+   { 0x46, KEY_CHANNELUP },
+   { 0x40, KEY_CHANNELDOWN },
+   { 0x08, KEY_ZOOM },
+   { 0x42, KEY_RECORD },
+   { 0x5a, KEY_STOP },
 };
 
 static struct rc_map_list lme2510_map = {
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c 
b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index 31f31fc..6e3ca72 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -286,15 +286,25 @@ static void lme2510_int_response(struct urb *lme_urb)
switch (ibuf[0]) {
case 0xaa:
debug_data_snipet(1, "INT Remote data snipet", ibuf);
-   if ((ibuf[4] + ibuf[5]) == 0xff) {
-   key = RC_SCANCODE_NECX((ibuf[2] ^ 0xff) << 8 |
-  (ibuf[3] > 0) ? (ibuf[3] 
^ 0xff) : 0,
-  ibuf[5]);
-   deb_info(1, "INT Key =%08x", key);
-   if (adap_to_d(adap)->rc_dev != NULL)
-   rc_keydown(adap_to_d(

[PATCH 02/11] rc-core: improve ir-kbd-i2c get_key functions

2014-03-29 Thread David Härdeman
The arguments used for ir-kbd-i2c's get_key() functions are not
really suited for rc-core and the ir_raw/ir_key distinction is
just confusing.

Convert all of them to return a protocol/scancode/toggle triple instead.

Signed-off-by: David Härdeman 
---
 drivers/media/i2c/ir-kbd-i2c.c|   90 +++--
 drivers/media/pci/bt8xx/bttv-input.c  |8 ++-
 drivers/media/pci/cx88/cx88-input.c   |8 ++-
 drivers/media/pci/ivtv/ivtv-i2c.c |9 ++-
 drivers/media/pci/saa7134/saa7134-input.c |   76 +++-
 drivers/media/usb/cx231xx/cx231xx-input.c |   20 ++
 include/media/ir-kbd-i2c.h|6 +-
 include/media/rc-map.h|   10 +++
 8 files changed, 127 insertions(+), 100 deletions(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index c8fe135..143cb2b 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -62,8 +62,8 @@ module_param(debug, int, 0644);/* debug level (0,1,2) */
 
 /* --- */
 
-static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
-  int size, int offset)
+static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol,
+  u32 *scancode, u8 *ptoggle, int size, int offset)
 {
unsigned char buf[6];
int start, range, toggle, dev, code, ircode;
@@ -86,19 +86,10 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 
*ir_key, u32 *ir_raw,
if (!start)
/* no key pressed */
return 0;
-   /*
-* Hauppauge remotes (black/silver) always use
-* specific device ids. If we do not filter the
-* device ids then messages destined for devices
-* such as TVs (id=0) will get through causing
-* mis-fired events.
-*
-* We also filter out invalid key presses which
-* produce annoying debug log entries.
-*/
-   ircode= (start << 12) | (toggle << 11) | (dev << 6) | code;
-   if ((ircode & 0x1fff)==0x1fff)
-   /* invalid key press */
+
+   /* filter out invalid key presses */
+   ircode = (start << 12) | (toggle << 11) | (dev << 6) | code;
+   if ((ircode & 0x1fff) == 0x1fff)
return 0;
 
if (!range)
@@ -107,18 +98,20 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 
*ir_key, u32 *ir_raw,
dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n",
start, range, toggle, dev, code);
 
-   /* return key */
-   *ir_key = (dev << 8) | code;
-   *ir_raw = ircode;
+   *protocol = RC_TYPE_RC5;
+   *scancode = RC_SCANCODE_RC5(dev, code);
+   *ptoggle = toggle;
return 1;
 }
 
-static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+static int get_key_haup(struct IR_i2c *ir, enum rc_type *protocol,
+   u32 *scancode, u8 *toggle)
 {
-   return get_key_haup_common (ir, ir_key, ir_raw, 3, 0);
+   return get_key_haup_common (ir, protocol, scancode, toggle, 3, 0);
 }
 
-static int get_key_haup_xvr(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol,
+   u32 *scancode, u8 *toggle)
 {
int ret;
unsigned char buf[1] = { 0 };
@@ -133,10 +126,11 @@ static int get_key_haup_xvr(struct IR_i2c *ir, u32 
*ir_key, u32 *ir_raw)
if (ret != 1)
return (ret < 0) ? ret : -EINVAL;
 
-   return get_key_haup_common (ir, ir_key, ir_raw, 6, 3);
+   return get_key_haup_common(ir, protocol, scancode, toggle, 6, 3);
 }
 
-static int get_key_pixelview(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol,
+u32 *scancode, u8 *toggle)
 {
unsigned char b;
 
@@ -145,12 +139,15 @@ static int get_key_pixelview(struct IR_i2c *ir, u32 
*ir_key, u32 *ir_raw)
dprintk(1,"read error\n");
return -EIO;
}
-   *ir_key = b;
-   *ir_raw = b;
+
+   *protocol = RC_TYPE_OTHER;
+   *scancode = b;
+   *toggle = 0;
return 1;
 }
 
-static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_type *protocol,
+ u32 *scancode, u8 *toggle)
 {
unsigned char buf[4];
 
@@ -168,13 +165,14 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, u32 
*ir_key, u32 *ir_raw)
if(buf[0] != 0x1 ||  buf[1] != 0xfe)
return 0;
 
-   *ir_key = buf[2];
-   *ir_raw = (buf[2] << 8) | buf[3];
-
+   *protocol = RC_TYPE_UNKNOWN;
+   *scancode = buf[2];
+   *toggle = 0;
return 1;
 }
 
-static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+static 

[PATCH 03/11] rc-core: document the protocol type

2014-03-29 Thread David Härdeman
Right now the protocol information is not preserved, rc-core gets handed a
scancode but has no idea which protocol it corresponds to.

This patch (which required reading through the source/keymap for all drivers,
not fun) makes the protocol information explicit which is important
documentation and makes it easier to e.g. support multiple protocols with one
decoder (think rc5 and rc-streamzap). The information isn't used yet so there
should be no functional changes.

Signed-off-by: David Härdeman 
---
 drivers/media/i2c/ir-kbd-i2c.c  |5 +
 drivers/media/pci/bt8xx/bttv-input.c|   12 ++-
 drivers/media/pci/cx88/cx88-input.c |   26 ++-
 drivers/media/pci/dm1105/dm1105.c   |3 +
 drivers/media/pci/saa7134/saa7134-input.c   |6 +-
 drivers/media/pci/ttpci/budget-ci.c |8 +-
 drivers/media/rc/img-ir/img-ir-hw.c |8 +-
 drivers/media/rc/img-ir/img-ir-hw.h |3 +
 drivers/media/rc/img-ir/img-ir-jvc.c|4 +
 drivers/media/rc/img-ir/img-ir-nec.c|4 +
 drivers/media/rc/img-ir/img-ir-sanyo.c  |4 +
 drivers/media/rc/img-ir/img-ir-sharp.c  |4 +
 drivers/media/rc/img-ir/img-ir-sony.c   |   12 ++-
 drivers/media/rc/ir-jvc-decoder.c   |2 -
 drivers/media/rc/ir-nec-decoder.c   |2 -
 drivers/media/rc/ir-rc5-decoder.c   |5 +
 drivers/media/rc/ir-rc5-sz-decoder.c|2 -
 drivers/media/rc/ir-rc6-decoder.c   |   37 --
 drivers/media/rc/ir-sanyo-decoder.c |2 -
 drivers/media/rc/ir-sharp-decoder.c |2 -
 drivers/media/rc/ir-sony-decoder.c  |6 +-
 drivers/media/rc/rc-main.c  |   32 +
 drivers/media/usb/dvb-usb-v2/af9015.c   |   18 +++--
 drivers/media/usb/dvb-usb-v2/af9035.c   |9 +-
 drivers/media/usb/dvb-usb-v2/anysee.c   |3 +
 drivers/media/usb/dvb-usb-v2/az6007.c   |   25 ---
 drivers/media/usb/dvb-usb-v2/lmedm04.c  |9 +-
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c |   12 ++-
 drivers/media/usb/dvb-usb/dib0700_core.c|   16 +++-
 drivers/media/usb/dvb-usb/dib0700_devices.c |   24 ---
 drivers/media/usb/dvb-usb/dw2102.c  |7 +-
 drivers/media/usb/dvb-usb/m920x.c   |2 -
 drivers/media/usb/dvb-usb/pctv452e.c|8 +-
 drivers/media/usb/dvb-usb/ttusb2.c  |6 +-
 drivers/media/usb/em28xx/em28xx-input.c |   98 ---
 drivers/media/usb/tm6000/tm6000-input.c |   51 ++
 include/media/rc-core.h |6 +-
 37 files changed, 301 insertions(+), 182 deletions(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 143cb2b..f9c4233 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -261,8 +261,9 @@ static int ir_key_poll(struct IR_i2c *ir)
}
 
if (rc) {
-   dprintk(1, "%s: scancode = 0x%08x\n", __func__, scancode);
-   rc_keydown(ir->rc, scancode, toggle);
+   dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n",
+   __func__, protocol, scancode);
+   rc_keydown(ir->rc, protocol, scancode, toggle);
}
return 0;
 }
diff --git a/drivers/media/pci/bt8xx/bttv-input.c 
b/drivers/media/pci/bt8xx/bttv-input.c
index e745f5a..67c8d6b 100644
--- a/drivers/media/pci/bt8xx/bttv-input.c
+++ b/drivers/media/pci/bt8xx/bttv-input.c
@@ -73,12 +73,12 @@ static void ir_handle_key(struct bttv *btv)
 
if ((ir->mask_keydown && (gpio & ir->mask_keydown)) ||
(ir->mask_keyup   && !(gpio & ir->mask_keyup))) {
-   rc_keydown_notimeout(ir->dev, data, 0);
+   rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
} else {
/* HACK: Probably, ir->mask_keydown is missing
   for this board */
if (btv->c.type == BTTV_BOARD_WINFAST2000)
-   rc_keydown_notimeout(ir->dev, data, 0);
+   rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
 
rc_keyup(ir->dev);
}
@@ -103,7 +103,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
gpio, data,
(gpio & ir->mask_keyup) ? " up" : "up/down");
 
-   rc_keydown_notimeout(ir->dev, data, 0);
+   rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
if (keyup)
rc_keyup(ir->dev);
} else {
@@ -117,7 +117,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
if (keyup)
rc_keyup(ir->dev);
else
-   rc_keydown_notimeout(ir->dev, data, 0);
+   rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
}
 
ir->last_gpio = data | keyup;
@@ -241,8 +241,8 @@ static void bttv_rc5_timer_end(unsigned long data)
 

[PATCH 10/11] [RFC] rc-core: use the full 32 bits for NEC scancodes

2014-03-29 Thread David Härdeman
Using the full 32 bits for all kinds of NEC scancodes simplifies rc-core
and the nec decoder without any loss of functionality.

In order to maintain backwards compatibility, some heuristics are added
in rc-main.c to convert scancodes to NEC32 as necessary.

I plan to introduce a different ioctl later which makes the protocol
explicit (and which expects all NEC scancodes to be 32 bit, thereby
removing the need for guesswork).

Signed-off-by: David Härdeman 
---
 drivers/media/pci/saa7134/saa7134-input.c |6 +-
 drivers/media/rc/img-ir/img-ir-nec.c  |   79 ++--
 drivers/media/rc/ir-nec-decoder.c |   28 ++---
 drivers/media/rc/keymaps/rc-tivo.c|   95 ++---
 drivers/media/rc/rc-main.c|   53 
 drivers/media/usb/dvb-usb-v2/af9015.c |   22 +--
 drivers/media/usb/dvb-usb-v2/af9035.c |   15 +
 drivers/media/usb/dvb-usb-v2/az6007.c |   16 +
 drivers/media/usb/dvb-usb-v2/lmedm04.c|   12 +---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c   |   16 +
 drivers/media/usb/dvb-usb/dib0700_core.c  |   21 ++
 drivers/media/usb/em28xx/em28xx-input.c   |   14 +---
 include/media/rc-map.h|   16 -
 13 files changed, 151 insertions(+), 242 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-input.c 
b/drivers/media/pci/saa7134/saa7134-input.c
index 887429b..4ba61ff 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -342,11 +342,9 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, enum 
rc_type *protocol,
return -EIO;
}
 
-   if (data[9] != (unsigned char)(~data[8]))
-   return 0;
-
*protocol = RC_TYPE_NEC;
-   *scancode = RC_SCANCODE_NECX(data[11] << 8 | data[10], data[9]);
+   *scancode = RC_SCANCODE_NEC32(data[11] << 24 | data[10] << 16 |
+ data[9]  << 8  | data[8]);
*toggle = 0;
return 1;
 }
diff --git a/drivers/media/rc/img-ir/img-ir-nec.c 
b/drivers/media/rc/img-ir/img-ir-nec.c
index 40ee844..133ea45 100644
--- a/drivers/media/rc/img-ir/img-ir-nec.c
+++ b/drivers/media/rc/img-ir/img-ir-nec.c
@@ -5,42 +5,20 @@
  */
 
 #include "img-ir-hw.h"
-#include 
 
 /* Convert NEC data to a scancode */
 static int img_ir_nec_scancode(int len, u64 raw, enum rc_type *protocol,
   u32 *scancode, u64 enabled_protocols)
 {
-   unsigned int addr, addr_inv, data, data_inv;
/* a repeat code has no data */
if (!len)
return IMG_IR_REPEATCODE;
+
if (len != 32)
return -EINVAL;
-   /* raw encoding: ddDDaaAA */
-   addr = (raw >>  0) & 0xff;
-   addr_inv = (raw >>  8) & 0xff;
-   data = (raw >> 16) & 0xff;
-   data_inv = (raw >> 24) & 0xff;
-   if ((data_inv ^ data) != 0xff) {
-   /* 32-bit NEC (used by Apple and TiVo remotes) */
-   /* scan encoding: AAaaDDdd (LSBit first) */
-   *scancode = bitrev8(addr) << 24 |
-   bitrev8(addr_inv) << 16 |
-   bitrev8(data) <<  8 |
-   bitrev8(data_inv);
-   } else if ((addr_inv ^ addr) != 0xff) {
-   /* Extended NEC */
-   /* scan encoding: AAaaDD */
-   *scancode = addr << 16 |
-   addr_inv <<  8 |
-   data;
-   } else {
-   /* Normal NEC */
-   /* scan encoding: AADD */
-   *scancode = addr << 8 |
-   data;
-   }
+
+   /* raw encoding : ddDDaaAA -> scan encoding: AAaaDDdd */
+   *scancode = swab32((u32)raw);
*protocol = RC_TYPE_NEC;
return IMG_IR_SCANCODE;
 }
@@ -49,52 +27,9 @@ static int img_ir_nec_scancode(int len, u64 raw, enum 
rc_type *protocol,
 static int img_ir_nec_filter(const struct rc_scancode_filter *in,
 struct img_ir_filter *out, u64 protocols)
 {
-   unsigned int addr, addr_inv, data, data_inv;
-   unsigned int addr_m, addr_inv_m, data_m, data_inv_m;
-
-   data   = in->data & 0xff;
-   data_m = in->mask & 0xff;
-
-   if ((in->data | in->mask) & 0xff00) {
-   /* 32-bit NEC (used by Apple and TiVo remotes) */
-   /* scan encoding: AAaaDDdd (LSBit first) */
-   addr   = bitrev8((in->data >> 24) & 0xff);
-   addr_m = (in->mask >> 24) & 0xff;
-   addr_inv   = bitrev8((in->data >> 16) & 0xff);
-   addr_inv_m = (in->mask >> 16) & 0xff;
-   data   = bitrev8((in->data >>  8) & 0xff);
-   data_m = (in->mask >>  8) & 0xff;
-   data_inv   = bitrev8((in->data >>  0) & 0xff);
-   data_inv_m = (in->mask >>  0) & 0xff;
-   } else if ((in->data | in->mask) & 0x00ff) {
-   

[PATCH 06/11] rc-core: remove generic scancode filter

2014-03-29 Thread David Härdeman
The generic scancode filtering has questionable value and makes it
impossible to determine from userspace if there is an actual
scancode hw filter present or not.

So revert the generic parts.

Based on a patch from James Hogan , but this
version also makes sure that only the valid sysfs files are created
in the first place.

Signed-off-by: David Härdeman 
---
 drivers/media/rc/rc-main.c |   66 +---
 include/media/rc-core.h|2 +
 2 files changed, 45 insertions(+), 23 deletions(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index ba955ac..8675e07 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -634,7 +634,6 @@ EXPORT_SYMBOL_GPL(rc_repeat);
 static void ir_do_keydown(struct rc_dev *dev, enum rc_type protocol,
  u32 scancode, u32 keycode, u8 toggle)
 {
-   struct rc_scancode_filter *filter;
bool new_event = (!dev->keypressed   ||
  dev->last_protocol != protocol ||
  dev->last_scancode != scancode ||
@@ -643,11 +642,6 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_type 
protocol,
if (new_event && dev->keypressed)
ir_do_keyup(dev, false);
 
-   /* Generic scancode filtering */
-   filter = &dev->scancode_filters[RC_FILTER_NORMAL];
-   if (filter->mask && ((scancode ^ filter->data) & filter->mask))
-   return;
-
input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode);
 
if (new_event && keycode != KEY_RESERVED) {
@@ -1017,14 +1011,11 @@ static ssize_t store_protocols(struct device *device,
set_filter = (fattr->type == RC_FILTER_NORMAL)
? dev->s_filter : dev->s_wakeup_filter;
 
-   if (old_type != type && filter->mask) {
+   if (set_filter && old_type != type && filter->mask) {
local_filter = *filter;
if (!type) {
/* no protocol => clear filter */
ret = -1;
-   } else if (!set_filter) {
-   /* generic filtering => accept any filter */
-   ret = 0;
} else {
/* hardware filtering => try setting, otherwise clear */
ret = set_filter(dev, &local_filter);
@@ -1033,8 +1024,7 @@ static ssize_t store_protocols(struct device *device,
/* clear the filter */
local_filter.data = 0;
local_filter.mask = 0;
-   if (set_filter)
-   set_filter(dev, &local_filter);
+   set_filter(dev, &local_filter);
}
 
/* commit the new filter */
@@ -1078,7 +1068,9 @@ static ssize_t show_filter(struct device *device,
return -EINVAL;
 
mutex_lock(&dev->lock);
-   if (fattr->mask)
+   if (!dev->s_filter)
+   val = 0;
+   else if (fattr->mask)
val = dev->scancode_filters[fattr->type].mask;
else
val = dev->scancode_filters[fattr->type].data;
@@ -1202,27 +1194,45 @@ static RC_FILTER_ATTR(wakeup_filter, S_IRUGO|S_IWUSR,
 static RC_FILTER_ATTR(wakeup_filter_mask, S_IRUGO|S_IWUSR,
  show_filter, store_filter, RC_FILTER_WAKEUP, true);
 
-static struct attribute *rc_dev_attrs[] = {
+static struct attribute *rc_dev_protocol_attrs[] = {
&dev_attr_protocols.attr.attr,
+   NULL,
+};
+
+static struct attribute_group rc_dev_protocol_attr_grp = {
+   .attrs  = rc_dev_protocol_attrs,
+};
+
+static struct attribute *rc_dev_wakeup_protocol_attrs[] = {
&dev_attr_wakeup_protocols.attr.attr,
+   NULL,
+};
+
+static struct attribute_group rc_dev_wakeup_protocol_attr_grp = {
+   .attrs  = rc_dev_wakeup_protocol_attrs,
+};
+
+static struct attribute *rc_dev_filter_attrs[] = {
&dev_attr_filter.attr.attr,
&dev_attr_filter_mask.attr.attr,
-   &dev_attr_wakeup_filter.attr.attr,
-   &dev_attr_wakeup_filter_mask.attr.attr,
NULL,
 };
 
-static struct attribute_group rc_dev_attr_grp = {
-   .attrs  = rc_dev_attrs,
+static struct attribute_group rc_dev_filter_attr_grp = {
+   .attrs  = rc_dev_filter_attrs,
+};
+
+static struct attribute *rc_dev_wakeup_filter_attrs[] = {
+   &dev_attr_wakeup_filter.attr.attr,
+   &dev_attr_wakeup_filter_mask.attr.attr,
+   NULL,
 };
 
-static const struct attribute_group *rc_dev_attr_groups[] = {
-   &rc_dev_attr_grp,
-   NULL
+static struct attribute_group rc_dev_wakeup_filter_attr_grp = {
+   .attrs  = rc_dev_wakeup_filter_attrs,
 };
 
 static struct device_type rc_dev_type = {
-   .groups = rc_dev_attr_groups,
.release= rc_dev_release,
.uevent = rc_dev_uevent,
 };
@@ -1279,7 +1289,7 @@ int rc_register_device(struct rc_dev *dev)
static 

[PATCH 07/11] dib0700: NEC scancode cleanup

2014-03-29 Thread David Härdeman
the RC RX packet is defined as:

struct dib0700_rc_response {
...
u8 not_system;
u8 system;
...
u8 data;
u8 not_data;

The NEC protocol transmits in the order:
system
not_system
data
not_data

Note that the code defines the NEC extended scancode as:

scancode = be16_to_cpu(poll_reply->system16) << 8 | poll_reply->data;

i.e.

scancode = poll_reply->not_system << 16 |
   poll_reply->system << 8  |
   poll_reply->data;

Which, if the order *is* reversed, would mean that the scancode that
gets defined is in reality:

scancode = poll_reply->system << 16 |
   poll_reply->not_system << 8  |
   poll_reply->data;

Which is the same as the order used in drivers/media/rc/ir-nec-decoder.c.

This patch changes the code to match my assumption (the generated scancode
should, however, not change).

Signed-off-by: David Härdeman 
CC: Patrick Boettcher 
---
 drivers/media/usb/dvb-usb/dib0700_core.c |   28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c 
b/drivers/media/usb/dvb-usb/dib0700_core.c
index 6afe7ea..4f5caf5 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -658,13 +658,8 @@ out:
 struct dib0700_rc_response {
u8 report_id;
u8 data_state;
-   union {
-   u16 system16;
-   struct {
-   u8 not_system;
-   u8 system;
-   };
-   };
+   u8 system;
+   u8 not_system;
u8 data;
u8 not_data;
 };
@@ -712,20 +707,27 @@ static void dib0700_rc_urb_completion(struct urb *purb)
toggle = 0;
 
/* NEC protocol sends repeat code as 0 0 0 FF */
-   if ((poll_reply->system == 0x00) && (poll_reply->data == 0x00)
-   && (poll_reply->not_data == 0xff)) {
+   if (poll_reply->system == 0x00 &&
+   poll_reply->not_system == 0x00 &&
+   poll_reply->data   == 0x00 &&
+   poll_reply->not_data   == 0xff) {
poll_reply->data_state = 2;
break;
}
 
-   if ((poll_reply->system ^ poll_reply->not_system) != 0xff) {
+   if (poll_reply->data ^ poll_reply->not_data != 0xff) {
+   deb_data("NEC32 protocol\n");
+   scancode = RC_SCANCODE_NEC32(poll_reply->system << 
24 |
+poll_reply->not_system << 
16 |
+poll_reply->data   << 
8  |
+poll_reply->not_data);
+   } else if (poll_reply->system ^ poll_reply->not_system != 0xff) 
{
deb_data("NEC extended protocol\n");
-   /* NEC extended code - 24 bits */
-   scancode = 
RC_SCANCODE_NECX(be16_to_cpu(poll_reply->system16),
+   scancode = RC_SCANCODE_NECX(poll_reply->system << 8 |
+   poll_reply->not_system,
poll_reply->data);
} else {
deb_data("NEC normal protocol\n");
-   /* normal NEC code - 16 bits */
scancode = RC_SCANCODE_NEC(poll_reply->system,
   poll_reply->data);
}

--
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 09/11] saa7134: NEC scancode fix

2014-03-29 Thread David Härdeman
This driver codes the two address bytes in reverse order when compared to the
other drivers, so make it consistent (and update the keymap, note that the
result is a prefix change from 0x6b86 -> 0x866b, and the latter is pretty
common among the NECX keymaps. While not conclusive, it's still a strong hint
that the change is correct).

Signed-off-by: David Härdeman 
---
 drivers/media/pci/saa7134/saa7134-input.c |2 -
 drivers/media/rc/keymaps/rc-behold.c  |   68 +++--
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-input.c 
b/drivers/media/pci/saa7134/saa7134-input.c
index 43dd8bd..887429b 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -346,7 +346,7 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, enum 
rc_type *protocol,
return 0;
 
*protocol = RC_TYPE_NEC;
-   *scancode = RC_SCANCODE_NECX(((data[10] << 8) | data[11]), data[9]);
+   *scancode = RC_SCANCODE_NECX(data[11] << 8 | data[10], data[9]);
*toggle = 0;
return 1;
 }
diff --git a/drivers/media/rc/keymaps/rc-behold.c 
b/drivers/media/rc/keymaps/rc-behold.c
index d6519f8..520a96f 100644
--- a/drivers/media/rc/keymaps/rc-behold.c
+++ b/drivers/media/rc/keymaps/rc-behold.c
@@ -30,8 +30,8 @@ static struct rc_map_table behold[] = {
/*  0x1c0x12  *
 *  TV/FM  POWER  *
 **/
-   { 0x6b861c, KEY_TUNER },/* XXX KEY_TV / KEY_RADIO */
-   { 0x6b8612, KEY_POWER },
+   { 0x866b1c, KEY_TUNER },/* XXX KEY_TV / KEY_RADIO */
+   { 0x866b12, KEY_POWER },
 
/*  0x010x020x03  *
 *   1   2   3*
@@ -42,28 +42,28 @@ static struct rc_map_table behold[] = {
 *  0x070x080x09  *
 *   7   8   9*
 **/
-   { 0x6b8601, KEY_1 },
-   { 0x6b8602, KEY_2 },
-   { 0x6b8603, KEY_3 },
-   { 0x6b8604, KEY_4 },
-   { 0x6b8605, KEY_5 },
-   { 0x6b8606, KEY_6 },
-   { 0x6b8607, KEY_7 },
-   { 0x6b8608, KEY_8 },
-   { 0x6b8609, KEY_9 },
+   { 0x866b01, KEY_1 },
+   { 0x866b02, KEY_2 },
+   { 0x866b03, KEY_3 },
+   { 0x866b04, KEY_4 },
+   { 0x866b05, KEY_5 },
+   { 0x866b06, KEY_6 },
+   { 0x866b07, KEY_7 },
+   { 0x866b08, KEY_8 },
+   { 0x866b09, KEY_9 },
 
/*  0x0a0x000x17  *
 * RECALL0  MODE  *
 **/
-   { 0x6b860a, KEY_AGAIN },
-   { 0x6b8600, KEY_0 },
-   { 0x6b8617, KEY_MODE },
+   { 0x866b0a, KEY_AGAIN },
+   { 0x866b00, KEY_0 },
+   { 0x866b17, KEY_MODE },
 
/*  0x14  0x10*
 * ASPECT  FULLSCREEN *
 **/
-   { 0x6b8614, KEY_SCREEN },
-   { 0x6b8610, KEY_ZOOM },
+   { 0x866b14, KEY_SCREEN },
+   { 0x866b10, KEY_ZOOM },
 
/*  0x0b  *
 *   Up   *
@@ -74,17 +74,17 @@ static struct rc_map_table behold[] = {
 * 0x015  *
 * Down   *
 **/
-   { 0x6b860b, KEY_CHANNELUP },
-   { 0x6b8618, KEY_VOLUMEDOWN },
-   { 0x6b8616, KEY_OK },   /* XXX KEY_ENTER */
-   { 0x6b860c, KEY_VOLUMEUP },
-   { 0x6b8615, KEY_CHANNELDOWN },
+   { 0x866b0b, KEY_CHANNELUP },
+   { 0x866b18, KEY_VOLUMEDOWN },
+   { 0x866b16, KEY_OK },   /* XXX KEY_ENTER */
+   { 0x866b0c, KEY_VOLUMEUP },
+   { 0x866b15, KEY_CHANNELDOWN },
 
/*  0x110x0d  *
 *  MUTEINFO  *
 **/
-   { 0x6b8611, KEY_MUTE },
-   { 0x6b860d, KEY_INFO },
+   { 0x866b11, KEY_MUTE },
+   { 0x866b0d, KEY_INFO },
 
/*  0x0f0x1b0x1a  *
 * RECORD PLAY/PAUSE STOP *
@@ -93,26 +93,26 @@ static struct rc_map_table behold[] = {
 *TELETEXT  AUDIO  SOURCE *
 *   RED   YELLOW *
 **/
-   { 0x6b860f, KEY_RECORD },
-   { 0x6b861b, KEY_PLAYPAUSE },
-   { 0x6b861a, KEY_STOP },
-   { 0x6b860e, KEY_TEXT },
-   { 0x6b861f, KEY_RED },  /*XXX KEY_AUDIO */
-   { 0x6b861e, KEY_VIDEO },
+   { 0x866b0f, KEY_RECORD },
+   { 0x866b1b, KEY_PLAYPAUSE },
+   { 0x866b1a, KEY_STOP },
+   { 0x866b0e, KEY_TEXT },
+   { 0x866b1f, KEY_RED },  /*XXX KEY_AUDIO */
+   { 0x866b1e, KEY_VIDEO },
 
/*  0x1d   0x13 0x19  *
 * SLEEP  PREVIEW   DVB   *
 * GREENBLUE  *
 **/
-   { 0x6b861d, KEY_SLEEP },
-   { 0x6b8613, KEY_GREEN },
-   { 0x6b8619, KEY_BLUE }, /* XXX KEY_SAT  */
+   { 0x866b1d, KEY_SLEEP },
+   { 0x866b13, KEY_GREEN },
+   { 0x866b19, KEY_BLUE }, /* XXX KEY_SAT  */
 
/*  0x58 

[PATCH 04/11] rc-core: do not change 32bit NEC scancode format for now

2014-03-29 Thread David Härdeman
This reverts 18bc17448147e93f31cc9b1a83be49f1224657b2

The patch ignores the fact that NEC32 scancodes are generated not only in the
NEC raw decoder but also directly in some drivers. Whichever approach is chosen
it should be consistent across drivers and this patch needs more discussion.

Furthermore, I'm convinced that we have to stop playing games trying to
decipher the "meaning" of NEC scancodes (what's the customer/vendor/address,
which byte is the MSB, etc).

This patch is in preparation for the next few patches in this series.

Signed-off-by: David Härdeman 
---
 drivers/media/rc/img-ir/img-ir-nec.c |   27 ++-
 drivers/media/rc/ir-nec-decoder.c|5 --
 drivers/media/rc/keymaps/rc-tivo.c   |   86 +-
 3 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/drivers/media/rc/img-ir/img-ir-nec.c 
b/drivers/media/rc/img-ir/img-ir-nec.c
index c0111d6..40ee844 100644
--- a/drivers/media/rc/img-ir/img-ir-nec.c
+++ b/drivers/media/rc/img-ir/img-ir-nec.c
@@ -5,6 +5,7 @@
  */
 
 #include "img-ir-hw.h"
+#include 
 
 /* Convert NEC data to a scancode */
 static int img_ir_nec_scancode(int len, u64 raw, enum rc_type *protocol,
@@ -23,11 +24,11 @@ static int img_ir_nec_scancode(int len, u64 raw, enum 
rc_type *protocol,
data_inv = (raw >> 24) & 0xff;
if ((data_inv ^ data) != 0xff) {
/* 32-bit NEC (used by Apple and TiVo remotes) */
-   /* scan encoding: aaAAddDD */
-   *scancode = addr_inv << 24 |
-   addr << 16 |
-   data_inv <<  8 |
-   data;
+   /* scan encoding: AAaaDDdd (LSBit first) */
+   *scancode = bitrev8(addr) << 24 |
+   bitrev8(addr_inv) << 16 |
+   bitrev8(data) <<  8 |
+   bitrev8(data_inv);
} else if ((addr_inv ^ addr) != 0xff) {
/* Extended NEC */
/* scan encoding: AAaaDD */
@@ -56,13 +57,15 @@ static int img_ir_nec_filter(const struct 
rc_scancode_filter *in,
 
if ((in->data | in->mask) & 0xff00) {
/* 32-bit NEC (used by Apple and TiVo remotes) */
-   /* scan encoding: aaAAddDD */
-   addr_inv   = (in->data >> 24) & 0xff;
-   addr_inv_m = (in->mask >> 24) & 0xff;
-   addr   = (in->data >> 16) & 0xff;
-   addr_m = (in->mask >> 16) & 0xff;
-   data_inv   = (in->data >>  8) & 0xff;
-   data_inv_m = (in->mask >>  8) & 0xff;
+   /* scan encoding: AAaaDDdd (LSBit first) */
+   addr   = bitrev8((in->data >> 24) & 0xff);
+   addr_m = (in->mask >> 24) & 0xff;
+   addr_inv   = bitrev8((in->data >> 16) & 0xff);
+   addr_inv_m = (in->mask >> 16) & 0xff;
+   data   = bitrev8((in->data >>  8) & 0xff);
+   data_m = (in->mask >>  8) & 0xff;
+   data_inv   = bitrev8((in->data >>  0) & 0xff);
+   data_inv_m = (in->mask >>  0) & 0xff;
} else if ((in->data | in->mask) & 0x00ff) {
/* Extended NEC */
/* scan encoding AAaaDD */
diff --git a/drivers/media/rc/ir-nec-decoder.c 
b/drivers/media/rc/ir-nec-decoder.c
index 735a509..c4333d5 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -172,10 +172,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
if (send_32bits) {
/* NEC transport, but modified protocol, used by at
 * least Apple and TiVo remotes */
-   scancode = not_address << 24 |
-  address << 16 |
-  not_command <<  8 |
-  command;
+   scancode = data->bits;
IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", 
scancode);
} else if ((address ^ not_address) != 0xff) {
/* Extended NEC */
diff --git a/drivers/media/rc/keymaps/rc-tivo.c 
b/drivers/media/rc/keymaps/rc-tivo.c
index 5cc1b45..454e062 100644
--- a/drivers/media/rc/keymaps/rc-tivo.c
+++ b/drivers/media/rc/keymaps/rc-tivo.c
@@ -15,62 +15,62 @@
  * Initial mapping is for the TiVo remote included in the Nero LiquidTV bundle,
  * which also ships with a TiVo-branded IR transceiver, supported by the mceusb
  * driver. Note that the remote uses an NEC-ish protocol, but instead of having
- * a command/not_command pair, it has a vendor ID of 0x3085, but some keys, the
+ * a command/not_command pair, it has a vendor ID of 0xa10c, but some keys, the
  * NEC extended checksums do pass, so the table presently has the intended
  * values and the checksum-passed versions for those keys.
  */
 static struct rc_map_table tivo[] = {
-   { 0x3

Re: FireDTV / w_scan / no data from NIT(actual)

2014-03-29 Thread Steven Toth
> Only is goes already wrong with the init scan I only get: "Info: no data
> from NIT(actual)"

I suspect either their isn't a NIT(actual) table on your frequency, or
the tool isn't waiting long enough for the NIT table to arrive.

- Steve

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


FireDTV / w_scan / no data from NIT(actual)

2014-03-29 Thread Podium B.V.


Hi all,

I am new to this mailinglist, but I couldn't find any help in forums
so in the IRC someone suggested to mail my question here.

I am trying to get my FireDTV to tune on a mux so I can generate a 
summary of bitrates
of streams within the mux. So my goal is not to watch Digitale TV on my 
Linux system.


Only is goes already wrong with the init scan I only get: "Info: no 
data from NIT(actual)"


I tried to summary all the info here : http://pastebin.com/kSwxBsaU
The OS I'm using is ubuntu 13.10 at the moment and I also tried / installed
the latest build:

cd /usr/src
sudo git clone git://linuxtv.org/media_build.git
sudo ./build
sudo make install
sudo reboot

Does anyone has an idea what I am doing wrong ? Or missing ?
I'm new to DVB-C on Linux.

Kind regards!
Ed



--
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 for v3.15] Fix patch merge mistake

2014-03-29 Thread Hans Verkuil
Commit 37571b163c15831cd0a213151c21387363dbf15b ("em28xx-dvb: fix PCTV 461e
tuner I2C binding") was merged incorrectly and one chunk ended up in the
wrong function causing a compile error.

Signed-off-by: Hans Verkuil 

diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
b/drivers/media/usb/em28xx/em28xx-dvb.c
index 71e1fca..f599b18 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -1603,7 +1603,6 @@ static int em28xx_dvb_suspend(struct em28xx *dev)
em28xx_info("Suspending DVB extension");
if (dev->dvb) {
struct em28xx_dvb *dvb = dev->dvb;
-   struct i2c_client *client = dvb->i2c_client_tuner;
 
if (dvb->fe[0]) {
ret = dvb_frontend_suspend(dvb->fe[0]);
@@ -1631,6 +1630,7 @@ static int em28xx_dvb_resume(struct em28xx *dev)
em28xx_info("Resuming DVB extension");
if (dev->dvb) {
struct em28xx_dvb *dvb = dev->dvb;
+   struct i2c_client *client = dvb->i2c_client_tuner;
 
if (dvb->fe[0]) {
ret = dvb_frontend_resume(dvb->fe[0]);
--
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


mfc: fixed the request buffer but failed in enqueue a dequeued OUTPUT(input)

2014-03-29 Thread ayaka
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

My kernel is 3.13.7, as I have reported before, mfc encoder can't
request buffer, I increase the mfc size in dts file from 0x80
to 0x400, then it can request buffer now, but it can't enqueue
the input(OUTPUT in v4l2 side) buffer which is just dequeued after
stream has start.
Here is the log of samsung demo, I don't get any information in dmesg
root@kagami:~# ./mfc-encode -m /dev/video1 -c h264
mfc codec encoding example application
Andrzej Hajda 
Copyright 2012 Samsung Electronics Co., Ltd.

50.370398146:args.c:parse_args:187: codec: H264
50.386230729:mfc.c:mfc_create:87: MFC device /dev/video1 opened with fd=3
50.402226771:v4l_dev.c:v4l_req_bufs:116: Succesfully requested 16
buffers for device 3:0
50.402356979:func_dev.c:func_req_bufs:42: Succesfully requested 16
buffers for device -1:1
50.402523896:func_dev.c:func_enq_buf:113: Enqueued buffer 0/16 to -1:1
50.402677896:func_dev.c:func_enq_buf:113: Enqueued buffer 1/16 to -1:1
50.402819771:func_dev.c:func_enq_buf:113: Enqueued buffer 2/16 to -1:1
50.403051729:func_dev.c:func_enq_buf:113: Enqueued buffer 3/16 to -1:1
50.403199646:func_dev.c:func_enq_buf:113: Enqueued buffer 4/16 to -1:1
50.403604562:func_dev.c:func_enq_buf:113: Enqueued buffer 5/16 to -1:1
50.403880187:func_dev.c:func_enq_buf:113: Enqueued buffer 6/16 to -1:1
50.404194396:func_dev.c:func_enq_buf:113: Enqueued buffer 7/16 to -1:1
50.404580146:func_dev.c:func_enq_buf:113: Enqueued buffer 8/16 to -1:1
50.404951021:func_dev.c:func_enq_buf:113: Enqueued buffer 9/16 to -1:1
50.405400896:func_dev.c:func_enq_buf:113: Enqueued buffer 10/16 to -1:1
50.405554729:func_dev.c:func_enq_buf:113: Enqueued buffer 11/16 to -1:1
50.405721271:func_dev.c:func_enq_buf:113: Enqueued buffer 12/16 to -1:1
50.405791896:func_dev.c:func_enq_buf:113: Enqueued buffer 13/16 to -1:1
50.405933604:func_dev.c:func_enq_buf:113: Enqueued buffer 14/16 to -1:1
50.406003646:func_dev.c:func_enq_buf:113: Enqueued buffer 15/16 to -1:1
50.473507729:v4l_dev.c:v4l_req_bufs:116: Succesfully requested 4
buffers for device 3:1
50.473621146:func_dev.c:func_req_bufs:42: Succesfully requested 4
buffers for device 4:0
50.473815312:v4l_dev.c:v4l_enq_buf:211: Enqueued buffer 0/4 to 3:1
50.474005771:v4l_dev.c:v4l_enq_buf:211: Enqueued buffer 1/4 to 3:1
50.474252854:v4l_dev.c:v4l_enq_buf:211: Enqueued buffer 2/4 to 3:1
50.474754854:v4l_dev.c:v4l_enq_buf:211: Enqueued buffer 3/4 to 3:1
State [enq cnt/max]: [Off 0 0/0|Rdy 16 0/250] [Off 0 0/0|Off 4 0/0]
[Off 0 0/0|Off 0 0/0]
State [enq cnt/max]: [Off 0 0/0|Rdy 16 0/250] [Off 0 0/0|Off 4 0/0]
[Off 0 0/0|Off 0 0/0]
50.476985521:func_dev.c:func_deq_buf:79: Dequeued buffer 0/16 from
- -1:1 ret=25344
v4l_dev.c:v4l_enq_buf:207: error: Error 22 enq buffer 0/16 to 3:0
50.477464521:io_dev.c:process_chain:165: pair 0:1 ret=-1

I have tried [Linaro-mm-sig] [PATCH][RFC] mm: Don't put CMA pages on
per-cpu lists
but it doesn't have any effect and if I don't modify the size in dts
it will failed in request buffer either.


In the program wroten by myself(I have tested work in manufacturer's
3.5 kernel), it can't dequeue the OUPUT at all neither the second
frame in CAPTURE(with V4L2_CID_MPEG_VIDEO_HEADER_MODE in 0), of
course, there is not any frame in OUTPUT, it is impossible to get the
the second frame in CAPTURE.

Thank you


ayaka
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJTNrvoAAoJEPb4VsMIzTziUtwH/RBoyPSLUieV+fJ0+/KkvBxN
WlkFATzPJD+AuiF0co2ggWrx0DnA1M8qFGHecNJW6mf+oL9+kz+2ASFBT+g224Pa
q5m1ykAGGnfo1sVtcMOf+HcDxq2dYMG9AD8Cjo39oPZXxgeJLRl2Wd/uePIBIj/H
IBGHX7I94XCAgU9OzMq8TviqwE9pyXVMNCa9DX0XBGYKuJDkeKVgXZXt/loGa1BZ
IV74aS0jKN8iO7npWSgpTvWG4nSDtw7arDfPTR1N6CsqgJvY+z9K0sr3LFIzu/UW
gPUW+eK08qyeemZr5W39akf56x/B+pua8npB+H3NKSxVysTgVvBZ5YieupEfXrE=
=gquq
-END PGP SIGNATURE-
--
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