All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] rc-core cleanups
@ 2010-06-07 19:32 David Härdeman
  2010-06-07 19:32 ` [PATCH 1/8] ir-core: convert mantis to not use ir-functions.c David Härdeman
                   ` (7 more replies)
  0 siblings, 8 replies; 20+ messages in thread
From: David Härdeman @ 2010-06-07 19:32 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media

The following series is my current patch queue.

The first five patches remove some of the ir-functions.c legacy from hardware
drivers (sadly I don't have the hardware so I can only compile test the
resulting code).

The next two patches are the same sysfs centralization patches I've sent before
(see discussion in that thread).

The last patch merges the two main rc-core (ir-core) headers, which helps
readability for me at least...

Net result - 900 lines less code.

---

David Härdeman (8):
      ir-core: convert mantis to not use ir-functions.c
      ir-core: convert em28xx to not use ir-functions.c
      ir-core: partially convert cx88 to not use ir-functions.c
      ir-core: partially convert ir-kbd-i2c.c to not use ir-functions.c
      ir-core: partially convert bt8xx to not use ir-functions.c
      ir-core: centralize sysfs raw decoder enabling/disabling
      ir-core: move decoding state to ir_raw_event_ctrl
      ir-core: merge rc-map.h into ir-core.h


 drivers/media/IR/ir-core-priv.h                    |   40 +++
 drivers/media/IR/ir-functions.c                    |   89 -------
 drivers/media/IR/ir-jvc-decoder.c                  |  152 +-----------
 drivers/media/IR/ir-nec-decoder.c                  |  151 +-----------
 drivers/media/IR/ir-raw-event.c                    |  136 +++++------
 drivers/media/IR/ir-rc5-decoder.c                  |  165 +------------
 drivers/media/IR/ir-rc6-decoder.c                  |  154 +-----------
 drivers/media/IR/ir-sony-decoder.c                 |  155 +-----------
 drivers/media/IR/ir-sysfs.c                        |  252 ++++++++++++--------
 drivers/media/IR/keymaps/rc-adstech-dvb-t-pci.c    |    2 
 drivers/media/IR/keymaps/rc-apac-viewcomp.c        |    2 
 drivers/media/IR/keymaps/rc-asus-pc39.c            |    2 
 drivers/media/IR/keymaps/rc-ati-tv-wonder-hd-600.c |    2 
 drivers/media/IR/keymaps/rc-avermedia-a16d.c       |    2 
 drivers/media/IR/keymaps/rc-avermedia-cardbus.c    |    2 
 drivers/media/IR/keymaps/rc-avermedia-dvbt.c       |    2 
 .../media/IR/keymaps/rc-avermedia-m135a-rm-jx.c    |    2 
 drivers/media/IR/keymaps/rc-avermedia.c            |    2 
 drivers/media/IR/keymaps/rc-avertv-303.c           |    2 
 drivers/media/IR/keymaps/rc-behold-columbus.c      |    2 
 drivers/media/IR/keymaps/rc-behold.c               |    2 
 drivers/media/IR/keymaps/rc-budget-ci-old.c        |    2 
 drivers/media/IR/keymaps/rc-cinergy-1400.c         |    2 
 drivers/media/IR/keymaps/rc-cinergy.c              |    2 
 drivers/media/IR/keymaps/rc-dm1105-nec.c           |    2 
 drivers/media/IR/keymaps/rc-dntv-live-dvb-t.c      |    2 
 drivers/media/IR/keymaps/rc-dntv-live-dvbt-pro.c   |    2 
 drivers/media/IR/keymaps/rc-em-terratec.c          |    2 
 drivers/media/IR/keymaps/rc-empty.c                |    2 
 drivers/media/IR/keymaps/rc-encore-enltv-fm53.c    |    2 
 drivers/media/IR/keymaps/rc-encore-enltv.c         |    2 
 drivers/media/IR/keymaps/rc-encore-enltv2.c        |    2 
 drivers/media/IR/keymaps/rc-evga-indtube.c         |    2 
 drivers/media/IR/keymaps/rc-eztv.c                 |    2 
 drivers/media/IR/keymaps/rc-flydvb.c               |    2 
 drivers/media/IR/keymaps/rc-flyvideo.c             |    2 
 drivers/media/IR/keymaps/rc-fusionhdtv-mce.c       |    2 
 drivers/media/IR/keymaps/rc-gadmei-rm008z.c        |    2 
 drivers/media/IR/keymaps/rc-genius-tvgo-a11mce.c   |    2 
 drivers/media/IR/keymaps/rc-gotview7135.c          |    2 
 drivers/media/IR/keymaps/rc-hauppauge-new.c        |    2 
 drivers/media/IR/keymaps/rc-imon-mce.c             |    2 
 drivers/media/IR/keymaps/rc-imon-pad.c             |    2 
 drivers/media/IR/keymaps/rc-iodata-bctv7e.c        |    2 
 drivers/media/IR/keymaps/rc-kaiomy.c               |    2 
 drivers/media/IR/keymaps/rc-kworld-315u.c          |    2 
 .../media/IR/keymaps/rc-kworld-plus-tv-analog.c    |    2 
 drivers/media/IR/keymaps/rc-manli.c                |    2 
 drivers/media/IR/keymaps/rc-msi-tvanywhere-plus.c  |    2 
 drivers/media/IR/keymaps/rc-msi-tvanywhere.c       |    2 
 drivers/media/IR/keymaps/rc-nebula.c               |    2 
 .../media/IR/keymaps/rc-nec-terratec-cinergy-xs.c  |    2 
 drivers/media/IR/keymaps/rc-norwood.c              |    2 
 drivers/media/IR/keymaps/rc-npgtech.c              |    2 
 drivers/media/IR/keymaps/rc-pctv-sedna.c           |    2 
 drivers/media/IR/keymaps/rc-pinnacle-color.c       |    2 
 drivers/media/IR/keymaps/rc-pinnacle-grey.c        |    2 
 drivers/media/IR/keymaps/rc-pinnacle-pctv-hd.c     |    2 
 drivers/media/IR/keymaps/rc-pixelview-mk12.c       |    2 
 drivers/media/IR/keymaps/rc-pixelview-new.c        |    2 
 drivers/media/IR/keymaps/rc-pixelview.c            |    2 
 .../media/IR/keymaps/rc-powercolor-real-angel.c    |    2 
 drivers/media/IR/keymaps/rc-proteus-2309.c         |    2 
 drivers/media/IR/keymaps/rc-purpletv.c             |    2 
 drivers/media/IR/keymaps/rc-pv951.c                |    2 
 drivers/media/IR/keymaps/rc-rc5-hauppauge-new.c    |    2 
 drivers/media/IR/keymaps/rc-rc5-tv.c               |    2 
 .../media/IR/keymaps/rc-real-audio-220-32-keys.c   |    2 
 drivers/media/IR/keymaps/rc-tbs-nec.c              |    2 
 drivers/media/IR/keymaps/rc-terratec-cinergy-xs.c  |    2 
 drivers/media/IR/keymaps/rc-tevii-nec.c            |    2 
 drivers/media/IR/keymaps/rc-tt-1500.c              |    2 
 drivers/media/IR/keymaps/rc-videomate-s350.c       |    2 
 drivers/media/IR/keymaps/rc-videomate-tv-pvr.c     |    2 
 drivers/media/IR/keymaps/rc-winfast-usbii-deluxe.c |    2 
 drivers/media/IR/keymaps/rc-winfast.c              |    2 
 drivers/media/dvb/mantis/mantis_input.c            |    5 
 drivers/media/video/bt8xx/bttv-input.c             |   35 +--
 drivers/media/video/bt8xx/bttv.h                   |    1 
 drivers/media/video/bt8xx/bttvp.h                  |   11 -
 drivers/media/video/cx23885/cx23885-input.c        |   51 ----
 drivers/media/video/cx88/cx88-input.c              |   46 +---
 drivers/media/video/em28xx/em28xx-input.c          |   65 +----
 drivers/media/video/em28xx/em28xx.h                |    1 
 drivers/media/video/ir-kbd-i2c.c                   |   14 -
 drivers/media/video/saa7134/saa7134-input.c        |   61 +----
 include/media/ir-common.h                          |   22 --
 include/media/ir-core.h                            |  112 +++++++++
 include/media/ir-kbd-i2c.h                         |    3 
 include/media/rc-map.h                             |  121 ----------
 90 files changed, 545 insertions(+), 1431 deletions(-)
 delete mode 100644 include/media/rc-map.h

-- 
David Härdeman

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/8] ir-core: convert mantis to not use ir-functions.c
  2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
@ 2010-06-07 19:32 ` David Härdeman
  2010-06-07 19:32 ` [PATCH 2/8] ir-core: convert em28xx " David Härdeman
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: David Härdeman @ 2010-06-07 19:32 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media

Convert drivers/media/dvb/mantis/mantis_input.c to not use ir-functions.c

Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/media/dvb/mantis/mantis_input.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb/mantis/mantis_input.c b/drivers/media/dvb/mantis/mantis_input.c
index 3d4e466..a99489b 100644
--- a/drivers/media/dvb/mantis/mantis_input.c
+++ b/drivers/media/dvb/mantis/mantis_input.c
@@ -19,7 +19,7 @@
 */
 
 #include <linux/input.h>
-#include <media/ir-common.h>
+#include <media/ir-core.h>
 #include <linux/pci.h>
 
 #include "dmxdev.h"
@@ -104,7 +104,6 @@ EXPORT_SYMBOL_GPL(ir_mantis);
 int mantis_input_init(struct mantis_pci *mantis)
 {
 	struct input_dev *rc;
-	struct ir_input_state rc_state;
 	char name[80], dev[80];
 	int err;
 
@@ -120,8 +119,6 @@ int mantis_input_init(struct mantis_pci *mantis)
 	rc->name = name;
 	rc->phys = dev;
 
-	ir_input_init(rc, &rc_state, IR_TYPE_OTHER);
-
 	rc->id.bustype	= BUS_PCI;
 	rc->id.vendor	= mantis->vendor_id;
 	rc->id.product	= mantis->device_id;


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/8] ir-core: convert em28xx to not use ir-functions.c
  2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
  2010-06-07 19:32 ` [PATCH 1/8] ir-core: convert mantis to not use ir-functions.c David Härdeman
@ 2010-06-07 19:32 ` David Härdeman
  2010-06-27 10:23   ` Mauro Carvalho Chehab
  2010-06-07 19:32 ` [PATCH 3/8] ir-core: partially convert cx88 " David Härdeman
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: David Härdeman @ 2010-06-07 19:32 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media

Convert drivers/media/video/em28xx/em28xx-input.c to not use ir-functions.c

Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/media/video/em28xx/em28xx-input.c |   65 +++++++----------------------
 drivers/media/video/em28xx/em28xx.h       |    1 
 2 files changed, 17 insertions(+), 49 deletions(-)

diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index dffd026..c4d6027 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -64,17 +64,14 @@ struct em28xx_ir_poll_result {
 struct em28xx_IR {
 	struct em28xx *dev;
 	struct input_dev *input;
-	struct ir_input_state ir;
 	char name[32];
 	char phys[32];
 
 	/* poll external decoder */
 	int polling;
 	struct delayed_work work;
-	unsigned int last_toggle:1;
 	unsigned int full_code:1;
 	unsigned int last_readcount;
-	unsigned int repeat_interval;
 
 	int  (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *);
 
@@ -290,7 +287,6 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
 static void em28xx_ir_handle_key(struct em28xx_IR *ir)
 {
 	int result;
-	int do_sendkey = 0;
 	struct em28xx_ir_poll_result poll_result;
 
 	/* read the registers containing the IR status */
@@ -305,52 +301,28 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
 		ir->last_readcount, poll_result.rc_address,
 		poll_result.rc_data[0]);
 
-	if (ir->dev->chip_id == CHIP_ID_EM2874) {
+	if (poll_result.read_count > 0 &&
+	    poll_result.read_count != ir->last_readcount) {
+		if (ir->full_code)
+			ir_keydown(ir->input,
+				   poll_result.rc_address << 8 |
+				   poll_result.rc_data[0],
+				   poll_result.toggle_bit);
+		else
+			ir_keydown(ir->input,
+				   poll_result.rc_data[0],
+				   poll_result.toggle_bit);
+	}
+
+	if (ir->dev->chip_id == CHIP_ID_EM2874)
 		/* The em2874 clears the readcount field every time the
 		   register is read.  The em2860/2880 datasheet says that it
 		   is supposed to clear the readcount, but it doesn't.  So with
 		   the em2874, we are looking for a non-zero read count as
 		   opposed to a readcount that is incrementing */
 		ir->last_readcount = 0;
-	}
-
-	if (poll_result.read_count == 0) {
-		/* The button has not been pressed since the last read */
-	} else if (ir->last_toggle != poll_result.toggle_bit) {
-		/* A button has been pressed */
-		dprintk("button has been pressed\n");
-		ir->last_toggle = poll_result.toggle_bit;
-		ir->repeat_interval = 0;
-		do_sendkey = 1;
-	} else if (poll_result.toggle_bit == ir->last_toggle &&
-		   poll_result.read_count > 0 &&
-		   poll_result.read_count != ir->last_readcount) {
-		/* The button is still being held down */
-		dprintk("button being held down\n");
-
-		/* Debouncer for first keypress */
-		if (ir->repeat_interval++ > 9) {
-			/* Start repeating after 1 second */
-			do_sendkey = 1;
-		}
-	}
-
-	if (do_sendkey) {
-		dprintk("sending keypress\n");
-
-		if (ir->full_code)
-			ir_input_keydown(ir->input, &ir->ir,
-					 poll_result.rc_address << 8 |
-					 poll_result.rc_data[0]);
-		else
-			ir_input_keydown(ir->input, &ir->ir,
-					 poll_result.rc_data[0]);
-
-		ir_input_nokey(ir->input, &ir->ir);
-	}
-
-	ir->last_readcount = poll_result.read_count;
-	return;
+	else
+		ir->last_readcount = poll_result.read_count;
 }
 
 static void em28xx_ir_work(struct work_struct *work)
@@ -465,11 +437,6 @@ int em28xx_ir_init(struct em28xx *dev)
 	usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
 	strlcat(ir->phys, "/input0", sizeof(ir->phys));
 
-	/* Set IR protocol */
-	err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER);
-	if (err < 0)
-		goto err_out_free;
-
 	input_dev->name = ir->name;
 	input_dev->phys = ir->phys;
 	input_dev->id.bustype = BUS_USB;
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index b252d1b..6216786 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -32,6 +32,7 @@
 #include <linux/i2c.h>
 #include <linux/mutex.h>
 #include <media/ir-kbd-i2c.h>
+#include <media/ir-core.h>
 #if defined(CONFIG_VIDEO_EM28XX_DVB) || defined(CONFIG_VIDEO_EM28XX_DVB_MODULE)
 #include <media/videobuf-dvb.h>
 #endif


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/8] ir-core: partially convert cx88 to not use ir-functions.c
  2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
  2010-06-07 19:32 ` [PATCH 1/8] ir-core: convert mantis to not use ir-functions.c David Härdeman
  2010-06-07 19:32 ` [PATCH 2/8] ir-core: convert em28xx " David Härdeman
@ 2010-06-07 19:32 ` David Härdeman
  2010-06-07 19:32 ` [PATCH 4/8] ir-core: partially convert ir-kbd-i2c.c " David Härdeman
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: David Härdeman @ 2010-06-07 19:32 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media

Partially convert drivers/media/video/cx88/cx88-input.c to
not use ir-functions.c

Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/media/video/cx88/cx88-input.c |   46 +++++++++++----------------------
 1 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 0de9bdf..e6ecbf8 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 
 #include "cx88.h"
+#include <media/ir-core.h>
 #include <media/ir-common.h>
 
 #define MODULE_NAME "cx88xx"
@@ -38,8 +39,8 @@
 struct cx88_IR {
 	struct cx88_core *core;
 	struct input_dev *input;
-	struct ir_input_state ir;
 	struct ir_dev_props props;
+	u64 ir_type;
 
 	int users;
 
@@ -50,7 +51,6 @@ struct cx88_IR {
 	u32 sampling;
 	u32 samples[16];
 	int scount;
-	unsigned long release;
 
 	/* poll external decoder */
 	int polling;
@@ -124,29 +124,21 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
 
 		data = (data << 4) | ((gpio_key & 0xf0) >> 4);
 
-		ir_input_keydown(ir->input, &ir->ir, data);
-		ir_input_nokey(ir->input, &ir->ir);
+		ir_keydown(ir->input, data, 0);
 
 	} else if (ir->mask_keydown) {
 		/* bit set on keydown */
-		if (gpio & ir->mask_keydown) {
-			ir_input_keydown(ir->input, &ir->ir, data);
-		} else {
-			ir_input_nokey(ir->input, &ir->ir);
-		}
+		if (gpio & ir->mask_keydown)
+			ir_keydown(ir->input, data, 0);
 
 	} else if (ir->mask_keyup) {
 		/* bit cleared on keydown */
-		if (0 == (gpio & ir->mask_keyup)) {
-			ir_input_keydown(ir->input, &ir->ir, data);
-		} else {
-			ir_input_nokey(ir->input, &ir->ir);
-		}
+		if (0 == (gpio & ir->mask_keyup))
+			ir_keydown(ir->input, data, 0);
 
 	} else {
 		/* can't distinguish keydown/up :-/ */
-		ir_input_keydown(ir->input, &ir->ir, data);
-		ir_input_nokey(ir->input, &ir->ir);
+		ir_keydown(ir->input, data, 0);
 	}
 }
 
@@ -438,9 +430,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
 	snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name);
 	snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
 
-	err = ir_input_init(input_dev, &ir->ir, ir_type);
-	if (err < 0)
-		goto err_out_free;
+	ir->ir_type = ir_type;
 
 	input_dev->name = ir->name;
 	input_dev->phys = ir->phys;
@@ -515,8 +505,6 @@ void cx88_ir_irq(struct cx88_core *core)
 	}
 	if (!ir->scount) {
 		/* nothing to sample */
-		if (ir->ir.keypressed && time_after(jiffies, ir->release))
-			ir_input_nokey(ir->input, &ir->ir);
 		return;
 	}
 
@@ -552,7 +540,7 @@ void cx88_ir_irq(struct cx88_core *core)
 
 		if (ircode == 0) { /* key still pressed */
 			ir_dprintk("pulse distance decoded repeat code\n");
-			ir->release = jiffies + msecs_to_jiffies(120);
+			ir_repeat(ir->input);
 			break;
 		}
 
@@ -566,10 +554,8 @@ void cx88_ir_irq(struct cx88_core *core)
 			break;
 		}
 
-		ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f);
-
-		ir_input_keydown(ir->input, &ir->ir, (ircode >> 16) & 0x7f);
-		ir->release = jiffies + msecs_to_jiffies(120);
+		ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0xff);
+		ir_keydown(ir->input, (ircode >> 16) & 0xff, 0);
 		break;
 	case CX88_BOARD_HAUPPAUGE:
 	case CX88_BOARD_HAUPPAUGE_DVB_T1:
@@ -605,16 +591,16 @@ void cx88_ir_irq(struct cx88_core *core)
 		if ( dev != 0x1e && dev != 0x1f )
 			/* not a hauppauge remote */
 			break;
-		ir_input_keydown(ir->input, &ir->ir, code);
-		ir->release = jiffies + msecs_to_jiffies(120);
+		ir_keydown(ir->input, code, toggle);
 		break;
 	case CX88_BOARD_PINNACLE_PCTV_HD_800i:
 		ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
 		ir_dprintk("biphase decoded: %x\n", ircode);
 		if ((ircode & 0xfffff000) != 0x3000)
 			break;
-		ir_input_keydown(ir->input, &ir->ir, ircode & 0x3f);
-		ir->release = jiffies + msecs_to_jiffies(120);
+		/* Note: bit 0x800 being the toggle is assumed, not checked
+		   with real hardware  */
+		ir_keydown(ir->input, ircode & 0x3f, ircode & 0x0800 ? 1 : 0);
 		break;
 	}
 


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/8] ir-core: partially convert ir-kbd-i2c.c to not use ir-functions.c
  2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
                   ` (2 preceding siblings ...)
  2010-06-07 19:32 ` [PATCH 3/8] ir-core: partially convert cx88 " David Härdeman
@ 2010-06-07 19:32 ` David Härdeman
  2010-06-07 19:32 ` [PATCH 5/8] ir-core: partially convert bt8xx " David Härdeman
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: David Härdeman @ 2010-06-07 19:32 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media

Partially convert drivers/media/video/ir-kbd-i2c.c to
not use ir-functions.c

Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/media/video/ir-kbd-i2c.c |   14 ++++----------
 include/media/ir-kbd-i2c.h       |    2 +-
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 29d4397..27ae8bb 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -47,7 +47,7 @@
 #include <linux/i2c-id.h>
 #include <linux/workqueue.h>
 
-#include <media/ir-common.h>
+#include <media/ir-core.h>
 #include <media/ir-kbd-i2c.h>
 
 /* ----------------------------------------------------------------------- */
@@ -272,11 +272,8 @@ static void ir_key_poll(struct IR_i2c *ir)
 		return;
 	}
 
-	if (0 == rc) {
-		ir_input_nokey(ir->input, &ir->ir);
-	} else {
-		ir_input_keydown(ir->input, &ir->ir, ir_key);
-	}
+	if (rc)
+		ir_keydown(ir->input, ir_key, 0);
 }
 
 static void ir_work(struct work_struct *work)
@@ -439,10 +436,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		 dev_name(&client->dev));
 
 	/* init + register input device */
-	err = ir_input_init(input_dev, &ir->ir, ir_type);
-	if (err < 0)
-		goto err_out_free;
-
+	ir->ir_type = ir_type;
 	input_dev->id.bustype = BUS_I2C;
 	input_dev->name       = ir->name;
 	input_dev->phys       = ir->phys;
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 0506e45..5e96d7a 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -11,7 +11,7 @@ struct IR_i2c {
 	struct i2c_client      *c;
 	struct input_dev       *input;
 	struct ir_input_state  ir;
-
+	u64                    ir_type;
 	/* Used to avoid fast repeating */
 	unsigned char          old;
 


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 5/8] ir-core: partially convert bt8xx to not use ir-functions.c
  2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
                   ` (3 preceding siblings ...)
  2010-06-07 19:32 ` [PATCH 4/8] ir-core: partially convert ir-kbd-i2c.c " David Härdeman
@ 2010-06-07 19:32 ` David Härdeman
  2010-06-27 12:11   ` Mauro Carvalho Chehab
  2010-06-07 19:32 ` [PATCH 6/8] ir-core: centralize sysfs raw decoder enabling/disabling David Härdeman
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: David Härdeman @ 2010-06-07 19:32 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media

Partially convert drivers/media/video/bt8xx/bttv-input.c to
not use ir-functions.c.

Since the last user is gone with this patch, also remove a
bunch of code from ir-functions.c.

Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/media/IR/ir-functions.c             |   89 +--------------------------
 drivers/media/video/bt8xx/bttv-input.c      |   35 ++---------
 drivers/media/video/bt8xx/bttv.h            |    1 
 drivers/media/video/bt8xx/bttvp.h           |   11 ---
 drivers/media/video/cx23885/cx23885-input.c |   51 +--------------
 drivers/media/video/saa7134/saa7134-input.c |   61 +++----------------
 include/media/ir-common.h                   |   22 -------
 include/media/ir-kbd-i2c.h                  |    1 
 8 files changed, 27 insertions(+), 244 deletions(-)

diff --git a/drivers/media/IR/ir-functions.c b/drivers/media/IR/ir-functions.c
index db591e4..d7f47b2 100644
--- a/drivers/media/IR/ir-functions.c
+++ b/drivers/media/IR/ir-functions.c
@@ -31,67 +31,6 @@
 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
 MODULE_LICENSE("GPL");
 
-static int repeat = 1;
-module_param(repeat, int, 0444);
-MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)");
-
-/* -------------------------------------------------------------------------- */
-
-static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
-{
-	if (KEY_RESERVED == ir->keycode) {
-		printk(KERN_INFO "%s: unknown key: key=0x%02x down=%d\n",
-		       dev->name, ir->ir_key, ir->keypressed);
-		return;
-	}
-	IR_dprintk(1,"%s: key event code=%d down=%d\n",
-		dev->name,ir->keycode,ir->keypressed);
-	input_report_key(dev,ir->keycode,ir->keypressed);
-	input_sync(dev);
-}
-
-/* -------------------------------------------------------------------------- */
-
-int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
-		  const u64 ir_type)
-{
-	ir->ir_type = ir_type;
-
-	if (repeat)
-		set_bit(EV_REP, dev->evbit);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(ir_input_init);
-
-
-void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
-{
-	if (ir->keypressed) {
-		ir->keypressed = 0;
-		ir_input_key_event(dev,ir);
-	}
-}
-EXPORT_SYMBOL_GPL(ir_input_nokey);
-
-void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
-		      u32 ir_key)
-{
-	u32 keycode = ir_g_keycode_from_table(dev, ir_key);
-
-	if (ir->keypressed && ir->keycode != keycode) {
-		ir->keypressed = 0;
-		ir_input_key_event(dev,ir);
-	}
-	if (!ir->keypressed) {
-		ir->ir_key  = ir_key;
-		ir->keycode = keycode;
-		ir->keypressed = 1;
-		ir_input_key_event(dev,ir);
-	}
-}
-EXPORT_SYMBOL_GPL(ir_input_keydown);
-
 /* -------------------------------------------------------------------------- */
 /* extract mask bits out of data and pack them into the result */
 u32 ir_extract_bits(u32 data, u32 mask)
@@ -284,12 +223,10 @@ void ir_rc5_timer_end(unsigned long data)
 {
 	struct card_ir *ir = (struct card_ir *)data;
 	struct timeval tv;
-	unsigned long current_jiffies, timeout;
 	u32 gap;
 	u32 rc5 = 0;
 
 	/* get time */
-	current_jiffies = jiffies;
 	do_gettimeofday(&tv);
 
 	/* avoid overflow with gap >1s */
@@ -325,32 +262,10 @@ void ir_rc5_timer_end(unsigned long data)
 			u32 toggle = RC5_TOGGLE(rc5);
 			u32 instr = RC5_INSTR(rc5);
 
-			/* Good code, decide if repeat/repress */
-			if (toggle != RC5_TOGGLE(ir->last_rc5) ||
-			    instr != RC5_INSTR(ir->last_rc5)) {
-				IR_dprintk(1, "ir-common: instruction %x, toggle %x\n", instr,
-					toggle);
-				ir_input_nokey(ir->dev, &ir->ir);
-				ir_input_keydown(ir->dev, &ir->ir, instr);
-			}
-
-			/* Set/reset key-up timer */
-			timeout = current_jiffies +
-				  msecs_to_jiffies(ir->rc5_key_timeout);
-			mod_timer(&ir->timer_keyup, timeout);
-
-			/* Save code for repeat test */
-			ir->last_rc5 = rc5;
+			/* Good code */
+			ir_keydown(ir->dev, instr, toggle);
 		}
 	}
 }
 EXPORT_SYMBOL_GPL(ir_rc5_timer_end);
 
-void ir_rc5_timer_keyup(unsigned long data)
-{
-	struct card_ir *ir = (struct card_ir *)data;
-
-	IR_dprintk(1, "ir-common: key released\n");
-	ir_input_nokey(ir->dev, &ir->ir);
-}
-EXPORT_SYMBOL_GPL(ir_rc5_timer_keyup);
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index 814fd34..66cdc0d 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -30,10 +30,6 @@
 
 static int ir_debug;
 module_param(ir_debug, int, 0644);
-static int repeat_delay = 500;
-module_param(repeat_delay, int, 0644);
-static int repeat_period = 33;
-module_param(repeat_period, int, 0644);
 
 static int ir_rc5_remote_gap = 885;
 module_param(ir_rc5_remote_gap, int, 0644);
@@ -75,14 +71,11 @@ static void ir_handle_key(struct bttv *btv)
 
 	if ((ir->mask_keydown  &&  (0 != (gpio & ir->mask_keydown))) ||
 	    (ir->mask_keyup    &&  (0 == (gpio & ir->mask_keyup)))) {
-		ir_input_keydown(ir->dev, &ir->ir, data);
-	} else {
+		ir_keydown(ir->dev, data, 0);
+	} else if (btv->c.type == BTTV_BOARD_WINFAST2000) {
 		/* HACK: Probably, ir->mask_keydown is missing
 		   for this board */
-		if (btv->c.type == BTTV_BOARD_WINFAST2000)
-			ir_input_keydown(ir->dev, &ir->ir, data);
-
-		ir_input_nokey(ir->dev,&ir->ir);
+		ir_keydown(ir->dev, data, 0);
 	}
 
 }
@@ -106,9 +99,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
 			gpio, data,
 			(gpio & ir->mask_keyup) ? " up" : "up/down");
 
-		ir_input_keydown(ir->dev, &ir->ir, data);
-		if (keyup)
-			ir_input_nokey(ir->dev, &ir->ir);
+		ir_keydown(ir->dev, data, 0);
 	} else {
 		if ((ir->last_gpio & 1 << 31) == keyup)
 			return;
@@ -117,10 +108,8 @@ static void ir_enltv_handle_key(struct bttv *btv)
 			gpio, data,
 			(gpio & ir->mask_keyup) ? " up" : "down");
 
-		if (keyup)
-			ir_input_nokey(ir->dev, &ir->ir);
-		else
-			ir_input_keydown(ir->dev, &ir->ir, data);
+		if (!keyup)
+			ir_keydown(ir->dev, data, 0);
 	}
 
 	ir->last_gpio = data | keyup;
@@ -215,9 +204,6 @@ static void bttv_ir_start(struct bttv *btv, struct card_ir *ir)
 		ir->timer_end.function = ir_rc5_timer_end;
 		ir->timer_end.data = (unsigned long)ir;
 
-		init_timer(&ir->timer_keyup);
-		ir->timer_keyup.function = ir_rc5_timer_keyup;
-		ir->timer_keyup.data = (unsigned long)ir;
 		ir->shift_by = 1;
 		ir->start = 3;
 		ir->addr = 0x0;
@@ -370,10 +356,7 @@ int bttv_input_init(struct bttv *btv)
 	snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
 		 pci_name(btv->c.pci));
 
-	err = ir_input_init(input_dev, &ir->ir, ir_type);
-	if (err < 0)
-		goto err_out_free;
-
+	ir->ir_type = ir_type;
 	input_dev->name = ir->name;
 	input_dev->phys = ir->phys;
 	input_dev->id.bustype = BUS_PCI;
@@ -395,10 +378,6 @@ int bttv_input_init(struct bttv *btv)
 	if (err)
 		goto err_out_stop;
 
-	/* the remote isn't as bouncy as a keyboard */
-	ir->dev->rep[REP_DELAY] = repeat_delay;
-	ir->dev->rep[REP_PERIOD] = repeat_period;
-
 	return 0;
 
  err_out_stop:
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h
index 3ec2402..33882c8 100644
--- a/drivers/media/video/bt8xx/bttv.h
+++ b/drivers/media/video/bt8xx/bttv.h
@@ -17,6 +17,7 @@
 #include <linux/videodev2.h>
 #include <linux/i2c.h>
 #include <media/v4l2-device.h>
+#include <media/ir-core.h>
 #include <media/ir-common.h>
 #include <media/ir-kbd-i2c.h>
 #include <media/i2c-addr.h>
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index 6cccc2a..4b29863 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -41,6 +41,7 @@
 #include <linux/device.h>
 #include <media/videobuf-dma-sg.h>
 #include <media/tveeprom.h>
+#include <media/ir-core.h>
 #include <media/ir-common.h>
 
 
@@ -298,16 +299,6 @@ struct bttv_pll_info {
 	unsigned int pll_current;  /* Currently programmed ofreq */
 };
 
-/* for gpio-connected remote control */
-struct bttv_input {
-	struct input_dev      *dev;
-	struct ir_input_state ir;
-	char                  name[32];
-	char                  phys[32];
-	u32                   mask_keycode;
-	u32                   mask_keydown;
-};
-
 struct bttv_suspend_state {
 	u32  gpio_enable;
 	u32  gpio_data;
diff --git a/drivers/media/video/cx23885/cx23885-input.c b/drivers/media/video/cx23885/cx23885-input.c
index f7d0ad6..faf097d 100644
--- a/drivers/media/video/cx23885/cx23885-input.c
+++ b/drivers/media/video/cx23885/cx23885-input.c
@@ -36,6 +36,7 @@
  */
 
 #include <linux/input.h>
+#include <media/ir-core.h>
 #include <media/ir-common.h>
 #include <media/v4l2-subdev.h>
 
@@ -88,21 +89,8 @@ static void cx23885_input_process_raw_rc5(struct cx23885_dev *dev)
 	if (ir_input->addr != RC5_ADDR(rc5))
 		return;
 
-	/* Don't generate a keypress for RC-5 auto-repeated keypresses */
 	command = rc5_command(rc5);
-	if (RC5_TOGGLE(rc5) != RC5_TOGGLE(ir_input->last_rc5) ||
-	    command != rc5_command(ir_input->last_rc5) ||
-	    /* Catch T == 0, CMD == 0 (e.g. '0') as first keypress after init */
-	    RC5_START(ir_input->last_rc5) == 0) {
-		/* This keypress is differnet: not an auto repeat */
-		ir_input_nokey(ir_input->dev, &ir_input->ir);
-		ir_input_keydown(ir_input->dev, &ir_input->ir, command);
-	}
-	ir_input->last_rc5 = rc5;
-
-	/* Schedule when we should do the key up event: ir_input_nokey() */
-	mod_timer(&ir_input->timer_keyup,
-		  jiffies + msecs_to_jiffies(ir_input->rc5_key_timeout));
+	ir_keydown(ir_input->dev, command, RC5_TOGGLE(rc5));
 }
 
 static void cx23885_input_next_pulse_width_rc5(struct cx23885_dev *dev,
@@ -166,7 +154,6 @@ static void cx23885_input_process_pulse_widths_rc5(struct cx23885_dev *dev,
 						   bool add_eom)
 {
 	struct card_ir *ir_input = dev->ir_input;
-	struct ir_input_state *ir_input_state = &ir_input->ir;
 
 	u32 ns_pulse[RC5_HALF_BITS+1];
 	ssize_t num = 0;
@@ -185,7 +172,7 @@ static void cx23885_input_process_pulse_widths_rc5(struct cx23885_dev *dev,
 		}
 
 		/* Just drain the Rx FIFO, if we're called, but not RC-5 */
-		if (ir_input_state->ir_type != IR_TYPE_RC5)
+		if (ir_input->ir_type != IR_TYPE_RC5)
 			continue;
 
 		for (i = 0; i < count; i++)
@@ -242,8 +229,6 @@ void cx23885_input_rx_work_handler(struct cx23885_dev *dev, u32 events)
 
 static void cx23885_input_ir_start(struct cx23885_dev *dev)
 {
-	struct card_ir *ir_input = dev->ir_input;
-	struct ir_input_state *ir_input_state = &ir_input->ir;
 	struct v4l2_subdev_ir_parameters params;
 
 	if (dev->sd_ir == NULL)
@@ -251,23 +236,6 @@ static void cx23885_input_ir_start(struct cx23885_dev *dev)
 
 	atomic_set(&dev->ir_input_stopping, 0);
 
-	/* keyup timer set up, if needed */
-	switch (dev->board) {
-	case CX23885_BOARD_HAUPPAUGE_HVR1850:
-	case CX23885_BOARD_HAUPPAUGE_HVR1290:
-		setup_timer(&ir_input->timer_keyup,
-			    ir_rc5_timer_keyup,	/* Not actually RC-5 specific */
-			    (unsigned long) ir_input);
-		if (ir_input_state->ir_type == IR_TYPE_RC5) {
-			/*
-			 * RC-5 repeats a held key every
-			 * 64 bits * (2 * 32/36000) sec/bit = 113.778 ms
-			 */
-			ir_input->rc5_key_timeout = 115;
-		}
-		break;
-	}
-
 	v4l2_subdev_call(dev->sd_ir, ir, rx_g_parameters, &params);
 	switch (dev->board) {
 	case CX23885_BOARD_HAUPPAUGE_HVR1850:
@@ -302,7 +270,6 @@ static void cx23885_input_ir_start(struct cx23885_dev *dev)
 
 static void cx23885_input_ir_stop(struct cx23885_dev *dev)
 {
-	struct card_ir *ir_input = dev->ir_input;
 	struct v4l2_subdev_ir_parameters params;
 
 	if (dev->sd_ir == NULL)
@@ -326,13 +293,6 @@ static void cx23885_input_ir_stop(struct cx23885_dev *dev)
 	}
 
 	flush_scheduled_work();
-
-	switch (dev->board) {
-	case CX23885_BOARD_HAUPPAUGE_HVR1850:
-	case CX23885_BOARD_HAUPPAUGE_HVR1290:
-		del_timer_sync(&ir_input->timer_keyup);
-		break;
-	}
 }
 
 int cx23885_input_init(struct cx23885_dev *dev)
@@ -379,10 +339,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
 		 cx23885_boards[dev->board].name);
 	snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(dev->pci));
 
-	ret = ir_input_init(input_dev, &ir->ir, ir_type);
-	if (ret < 0)
-		goto err_out_free;
-
+	ir->ir_type = ir_type;
 	input_dev->name = ir->name;
 	input_dev->phys = ir->phys;
 	input_dev->id.bustype = BUS_PCI;
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 28c230d..562a514 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -46,14 +46,6 @@ module_param(ir_rc5_remote_gap, int, 0644);
 static int ir_rc5_key_timeout = 115;
 module_param(ir_rc5_key_timeout, int, 0644);
 
-static int repeat_delay = 500;
-module_param(repeat_delay, int, 0644);
-MODULE_PARM_DESC(repeat_delay, "delay before key repeat started");
-static int repeat_period = 33;
-module_param(repeat_period, int, 0644);
-MODULE_PARM_DESC(repeat_period, "repeat period between "
-    "keypresses when key is down");
-
 static unsigned int disable_other_ir;
 module_param(disable_other_ir, int, 0644);
 MODULE_PARM_DESC(disable_other_ir, "disable full codes of "
@@ -69,7 +61,6 @@ static int saa7134_rc5_irq(struct saa7134_dev *dev);
 static int saa7134_nec_irq(struct saa7134_dev *dev);
 static int saa7134_raw_decode_irq(struct saa7134_dev *dev);
 static void nec_task(unsigned long data);
-static void saa7134_nec_timer(unsigned long data);
 
 /* -------------------- GPIO generic keycode builder -------------------- */
 
@@ -102,27 +93,20 @@ static int build_key(struct saa7134_dev *dev)
 
 	switch (dev->board) {
 	case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
-		if (data == ir->mask_keycode)
-			ir_input_nokey(ir->dev, &ir->ir);
-		else
-			ir_input_keydown(ir->dev, &ir->ir, data);
+		if (data != ir->mask_keycode)
+			ir_keydown(ir->dev, data, 0);
 		return 0;
 	}
 
 	if (ir->polling) {
 		if ((ir->mask_keydown  &&  (0 != (gpio & ir->mask_keydown))) ||
-		    (ir->mask_keyup    &&  (0 == (gpio & ir->mask_keyup)))) {
-			ir_input_keydown(ir->dev, &ir->ir, data);
-		} else {
-			ir_input_nokey(ir->dev, &ir->ir);
-		}
+		    (ir->mask_keyup    &&  (0 == (gpio & ir->mask_keyup))))
+			ir_keydown(ir->dev, data, 0);
 	}
 	else {	/* IRQ driven mode - handle key press and release in one go */
 		if ((ir->mask_keydown  &&  (0 != (gpio & ir->mask_keydown))) ||
-		    (ir->mask_keyup    &&  (0 == (gpio & ir->mask_keyup)))) {
-			ir_input_keydown(ir->dev, &ir->ir, data);
-			ir_input_nokey(ir->dev, &ir->ir);
-		}
+		    (ir->mask_keyup    &&  (0 == (gpio & ir->mask_keyup))))
+			ir_keydown(ir->dev, data, 0);
 	}
 
 	return 0;
@@ -464,17 +448,12 @@ static int __saa7134_ir_start(void *priv)
 		init_timer(&ir->timer_end);
 		ir->timer_end.function = ir_rc5_timer_end;
 		ir->timer_end.data = (unsigned long)ir;
-		init_timer(&ir->timer_keyup);
-		ir->timer_keyup.function = ir_rc5_timer_keyup;
-		ir->timer_keyup.data = (unsigned long)ir;
 		ir->shift_by = 2;
 		ir->start = 0x2;
 		ir->addr = 0x17;
 		ir->rc5_key_timeout = ir_rc5_key_timeout;
 		ir->rc5_remote_gap = ir_rc5_remote_gap;
 	} else if (ir->nec_gpio) {
-		setup_timer(&ir->timer_keyup, saa7134_nec_timer,
-			    (unsigned long)dev);
 		tasklet_init(&ir->tlet, nec_task, (unsigned long)dev);
 	} else if (ir->raw_decode) {
 		/* set timer_end for code completion */
@@ -862,10 +841,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
 		ir->props.change_protocol = saa7134_ir_change_protocol;
 	}
 
-	err = ir_input_init(input_dev, &ir->ir, ir_type);
-	if (err < 0)
-		goto err_out_free;
-
+	ir->ir_type = ir_type;
 	input_dev->name = ir->name;
 	input_dev->phys = ir->phys;
 	input_dev->id.bustype = BUS_PCI;
@@ -883,10 +859,6 @@ int saa7134_input_init1(struct saa7134_dev *dev)
 	if (err)
 		goto err_out_free;
 
-	/* the remote isn't as bouncy as a keyboard */
-	ir->dev->rep[REP_DELAY] = repeat_delay;
-	ir->dev->rep[REP_PERIOD] = repeat_period;
-
 	return 0;
 
 err_out_free:
@@ -1082,16 +1054,6 @@ static int saa7134_rc5_irq(struct saa7134_dev *dev)
    The first pulse (start) has 9 + 4.5 ms
  */
 
-static void saa7134_nec_timer(unsigned long data)
-{
-	struct saa7134_dev *dev = (struct saa7134_dev *) data;
-	struct card_ir *ir = dev->remote;
-
-	dprintk("Cancel key repeat\n");
-
-	ir_input_nokey(ir->dev, &ir->ir);
-}
-
 static void nec_task(unsigned long data)
 {
 	struct saa7134_dev *dev = (struct saa7134_dev *) data;
@@ -1180,12 +1142,11 @@ static void nec_task(unsigned long data)
 		dprintk("scancode = 0x%02x (code = 0x%02x, notcode= 0x%02x)\n",
 			 ir->code, ircode, not_code);
 
-		ir_input_keydown(ir->dev, &ir->ir, ir->code);
-	} else
+		ir_keydown(ir->dev, ir->code, 0);
+	} else {
 		dprintk("Repeat last key\n");
-
-	/* Keep repeating the last key */
-	mod_timer(&ir->timer_keyup, jiffies + msecs_to_jiffies(150));
+		ir_repeat(ir->dev);
+	}
 
 	saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_P);
 }
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 528050e..8043a53 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -33,21 +33,11 @@
 #define RC5_ADDR(x)	(((x)>>6)&31)
 #define RC5_INSTR(x)	((x)&63)
 
-struct ir_input_state {
-	/* configuration */
-	u64      ir_type;
-
-	/* key info */
-	u32                ir_key;      /* ir scancode */
-	u32                keycode;     /* linux key code */
-	int                keypressed;  /* current state */
-};
-
 /* this was saa7134_ir and bttv_ir, moved here for
  * rc5 decoding. */
 struct card_ir {
 	struct input_dev        *dev;
-	struct ir_input_state   ir;
+	u64			ir_type;
 	char                    name[32];
 	char                    phys[32];
 	int			users;
@@ -73,8 +63,6 @@ struct card_ir {
 	/* RC5 gpio */
 	u32 rc5_gpio;
 	struct timer_list timer_end;	/* timer_end for code completion */
-	struct timer_list timer_keyup;	/* timer_end for key release */
-	u32 last_rc5;			/* last good rc5 code */
 	u32 last_bit;			/* last raw bit seen */
 	u32 code;			/* raw code under construction */
 	struct timeval base_time;	/* time of last seen code */
@@ -89,19 +77,11 @@ struct card_ir {
 };
 
 /* Routines from ir-functions.c */
-
-int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
-		   const u64 ir_type);
-void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
-void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
-		      u32 ir_key);
 u32  ir_extract_bits(u32 data, u32 mask);
 int  ir_dump_samples(u32 *samples, int count);
 int  ir_decode_biphase(u32 *samples, int count, int low, int high);
 int  ir_decode_pulsedistance(u32 *samples, int count, int low, int high);
 u32  ir_rc5_decode(unsigned int code);
-
 void ir_rc5_timer_end(unsigned long data);
-void ir_rc5_timer_keyup(unsigned long data);
 
 #endif
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 5e96d7a..13ea2aa 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -10,7 +10,6 @@ struct IR_i2c {
 
 	struct i2c_client      *c;
 	struct input_dev       *input;
-	struct ir_input_state  ir;
 	u64                    ir_type;
 	/* Used to avoid fast repeating */
 	unsigned char          old;


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 6/8] ir-core: centralize sysfs raw decoder enabling/disabling
  2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
                   ` (4 preceding siblings ...)
  2010-06-07 19:32 ` [PATCH 5/8] ir-core: partially convert bt8xx " David Härdeman
@ 2010-06-07 19:32 ` David Härdeman
  2010-06-07 19:32 ` [PATCH 7/8] ir-core: move decoding state to ir_raw_event_ctrl David Härdeman
  2010-06-07 19:32 ` [PATCH 8/8] ir-core: merge rc-map.h into ir-core.h David Härdeman
  7 siblings, 0 replies; 20+ messages in thread
From: David Härdeman @ 2010-06-07 19:32 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media

With the current logic, each raw decoder needs to add a copy of the exact
same sysfs code. This is both unnecessary and also means that (re)loading
an IR driver after raw decoder modules have been loaded won't work as
expected.

This patch moves that logic into ir-raw-event and adds a single sysfs
file per device.

Reading that file returns something like:

	"rc5 [rc6] nec jvc [sony]"

(with enabled protocols in [] brackets)

Writing either "+protocol" or "-protocol" to that file will
enable or disable the according protocol decoder.

An additional benefit is that the disabling of a decoder will be
remembered across module removal/insertion so a previously
disabled decoder won't suddenly be activated again. The default
setting is to enable all decoders.

This is also necessary for the next patch which moves even more decoder
state into the central raw decoding structs.

Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/media/IR/ir-core-priv.h    |    3 
 drivers/media/IR/ir-jvc-decoder.c  |   64 ---------
 drivers/media/IR/ir-nec-decoder.c  |   64 ---------
 drivers/media/IR/ir-raw-event.c    |  112 +++++++++-------
 drivers/media/IR/ir-rc5-decoder.c  |   64 ---------
 drivers/media/IR/ir-rc6-decoder.c  |   64 ---------
 drivers/media/IR/ir-sony-decoder.c |   64 ---------
 drivers/media/IR/ir-sysfs.c        |  252 +++++++++++++++++++++---------------
 8 files changed, 231 insertions(+), 456 deletions(-)

diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index b79446f..3072e55 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -21,6 +21,7 @@
 struct ir_raw_handler {
 	struct list_head list;
 
+	u64 protocols; /* which are handled by this handler */
 	int (*decode)(struct input_dev *input_dev, struct ir_raw_event event);
 	int (*raw_register)(struct input_dev *input_dev);
 	int (*raw_unregister)(struct input_dev *input_dev);
@@ -32,6 +33,7 @@ struct ir_raw_event_ctrl {
 	ktime_t				last_event;	/* when last event occurred */
 	enum raw_event_type		last_type;	/* last event type */
 	struct input_dev		*input_dev;	/* pointer to the parent input_dev */
+	u64				enabled_protocols; /* enabled raw protocol decoders */
 };
 
 /* macros for IR decoders */
@@ -73,6 +75,7 @@ void ir_unregister_class(struct input_dev *input_dev);
 /*
  * Routines from ir-raw-event.c to be used internally and by decoders
  */
+u64 ir_raw_get_allowed_protocols(void);
 int ir_raw_event_register(struct input_dev *input_dev);
 void ir_raw_event_unregister(struct input_dev *input_dev);
 int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);
diff --git a/drivers/media/IR/ir-jvc-decoder.c b/drivers/media/IR/ir-jvc-decoder.c
index 0b80494..1055de4 100644
--- a/drivers/media/IR/ir-jvc-decoder.c
+++ b/drivers/media/IR/ir-jvc-decoder.c
@@ -41,7 +41,6 @@ enum jvc_state {
 struct decoder_data {
 	struct list_head	list;
 	struct ir_input_dev	*ir_dev;
-	int			enabled:1;
 
 	/* State machine control */
 	enum jvc_state		state;
@@ -72,53 +71,6 @@ static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
 	return data;
 }
 
-static ssize_t store_enabled(struct device *d,
-			     struct device_attribute *mattr,
-			     const char *buf,
-			     size_t len)
-{
-	unsigned long value;
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (strict_strtoul(buf, 10, &value) || value > 1)
-		return -EINVAL;
-
-	data->enabled = value;
-
-	return len;
-}
-
-static ssize_t show_enabled(struct device *d,
-			     struct device_attribute *mattr, char *buf)
-{
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (data->enabled)
-		return sprintf(buf, "1\n");
-	else
-	return sprintf(buf, "0\n");
-}
-
-static DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR, show_enabled, store_enabled);
-
-static struct attribute *decoder_attributes[] = {
-	&dev_attr_enabled.attr,
-	NULL
-};
-
-static struct attribute_group decoder_attribute_group = {
-	.name	= "jvc_decoder",
-	.attrs	= decoder_attributes,
-};
-
 /**
  * ir_jvc_decode() - Decode one JVC pulse or space
  * @input_dev:	the struct input_dev descriptor of the device
@@ -135,7 +87,7 @@ static int ir_jvc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 	if (!data)
 		return -EINVAL;
 
-	if (!data->enabled)
+	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_JVC))
 		return 0;
 
 	if (IS_RESET(ev)) {
@@ -253,21 +205,12 @@ static int ir_jvc_register(struct input_dev *input_dev)
 {
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
 	struct decoder_data *data;
-	int rc;
-
-	rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-	if (rc < 0)
-		return rc;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
+	if (!data)
 		return -ENOMEM;
-	}
 
 	data->ir_dev = ir_dev;
-	data->enabled = 1;
-
 	spin_lock(&decoder_lock);
 	list_add_tail(&data->list, &decoder_list);
 	spin_unlock(&decoder_lock);
@@ -284,8 +227,6 @@ static int ir_jvc_unregister(struct input_dev *input_dev)
 	if (!data)
 		return 0;
 
-	sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-
 	spin_lock(&decoder_lock);
 	list_del(&data->list);
 	spin_unlock(&decoder_lock);
@@ -294,6 +235,7 @@ static int ir_jvc_unregister(struct input_dev *input_dev)
 }
 
 static struct ir_raw_handler jvc_handler = {
+	.protocols	= IR_TYPE_JVC,
 	.decode		= ir_jvc_decode,
 	.raw_register	= ir_jvc_register,
 	.raw_unregister	= ir_jvc_unregister,
diff --git a/drivers/media/IR/ir-nec-decoder.c b/drivers/media/IR/ir-nec-decoder.c
index ba79233..2cc2b92 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -43,7 +43,6 @@ enum nec_state {
 struct decoder_data {
 	struct list_head	list;
 	struct ir_input_dev	*ir_dev;
-	int			enabled:1;
 
 	/* State machine control */
 	enum nec_state		state;
@@ -71,53 +70,6 @@ static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
 	return data;
 }
 
-static ssize_t store_enabled(struct device *d,
-			     struct device_attribute *mattr,
-			     const char *buf,
-			     size_t len)
-{
-	unsigned long value;
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (strict_strtoul(buf, 10, &value) || value > 1)
-		return -EINVAL;
-
-	data->enabled = value;
-
-	return len;
-}
-
-static ssize_t show_enabled(struct device *d,
-			     struct device_attribute *mattr, char *buf)
-{
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (data->enabled)
-		return sprintf(buf, "1\n");
-	else
-	return sprintf(buf, "0\n");
-}
-
-static DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR, show_enabled, store_enabled);
-
-static struct attribute *decoder_attributes[] = {
-	&dev_attr_enabled.attr,
-	NULL
-};
-
-static struct attribute_group decoder_attribute_group = {
-	.name	= "nec_decoder",
-	.attrs	= decoder_attributes,
-};
-
 /**
  * ir_nec_decode() - Decode one NEC pulse or space
  * @input_dev:	the struct input_dev descriptor of the device
@@ -136,7 +88,7 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 	if (!data)
 		return -EINVAL;
 
-	if (!data->enabled)
+	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_NEC))
 		return 0;
 
 	if (IS_RESET(ev)) {
@@ -260,21 +212,12 @@ static int ir_nec_register(struct input_dev *input_dev)
 {
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
 	struct decoder_data *data;
-	int rc;
-
-	rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-	if (rc < 0)
-		return rc;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
+	if (!data)
 		return -ENOMEM;
-	}
 
 	data->ir_dev = ir_dev;
-	data->enabled = 1;
-
 	spin_lock(&decoder_lock);
 	list_add_tail(&data->list, &decoder_list);
 	spin_unlock(&decoder_lock);
@@ -291,8 +234,6 @@ static int ir_nec_unregister(struct input_dev *input_dev)
 	if (!data)
 		return 0;
 
-	sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-
 	spin_lock(&decoder_lock);
 	list_del(&data->list);
 	spin_unlock(&decoder_lock);
@@ -301,6 +242,7 @@ static int ir_nec_unregister(struct input_dev *input_dev)
 }
 
 static struct ir_raw_handler nec_handler = {
+	.protocols	= IR_TYPE_NEC,
 	.decode		= ir_nec_decode,
 	.raw_register	= ir_nec_register,
 	.raw_unregister	= ir_nec_unregister,
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index ea68a3f..eeca8a8 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -21,8 +21,9 @@
 #define MAX_IR_EVENT_SIZE      512
 
 /* Used to handle IR raw handler extensions */
-static LIST_HEAD(ir_raw_handler_list);
 static DEFINE_SPINLOCK(ir_raw_handler_lock);
+static LIST_HEAD(ir_raw_handler_list);
+static u64 available_protocols;
 
 /**
  * RUN_DECODER()	- runs an operation on all IR decoders
@@ -65,52 +66,6 @@ static void ir_raw_event_work(struct work_struct *work)
 		RUN_DECODER(decode, raw->input_dev, ev);
 }
 
-int ir_raw_event_register(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir = input_get_drvdata(input_dev);
-	int rc;
-
-	ir->raw = kzalloc(sizeof(*ir->raw), GFP_KERNEL);
-	if (!ir->raw)
-		return -ENOMEM;
-
-	ir->raw->input_dev = input_dev;
-	INIT_WORK(&ir->raw->rx_work, ir_raw_event_work);
-
-	rc = kfifo_alloc(&ir->raw->kfifo, sizeof(s64) * MAX_IR_EVENT_SIZE,
-			 GFP_KERNEL);
-	if (rc < 0) {
-		kfree(ir->raw);
-		ir->raw = NULL;
-		return rc;
-	}
-
-	rc = RUN_DECODER(raw_register, input_dev);
-	if (rc < 0) {
-		kfifo_free(&ir->raw->kfifo);
-		kfree(ir->raw);
-		ir->raw = NULL;
-		return rc;
-	}
-
-	return rc;
-}
-
-void ir_raw_event_unregister(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir = input_get_drvdata(input_dev);
-
-	if (!ir->raw)
-		return;
-
-	cancel_work_sync(&ir->raw->rx_work);
-	RUN_DECODER(raw_unregister, input_dev);
-
-	kfifo_free(&ir->raw->kfifo);
-	kfree(ir->raw);
-	ir->raw = NULL;
-}
-
 /**
  * ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
  * @input_dev:	the struct input_dev device descriptor
@@ -204,6 +159,66 @@ void ir_raw_event_handle(struct input_dev *input_dev)
 }
 EXPORT_SYMBOL_GPL(ir_raw_event_handle);
 
+/* used internally by the sysfs interface */
+u64
+ir_raw_get_allowed_protocols()
+{
+	u64 protocols;
+	spin_lock(&ir_raw_handler_lock);
+	protocols = available_protocols;
+	spin_unlock(&ir_raw_handler_lock);
+	return protocols;
+}
+
+/*
+ * Used to (un)register raw event clients
+ */
+int ir_raw_event_register(struct input_dev *input_dev)
+{
+	struct ir_input_dev *ir = input_get_drvdata(input_dev);
+	int rc;
+
+	ir->raw = kzalloc(sizeof(*ir->raw), GFP_KERNEL);
+	if (!ir->raw)
+		return -ENOMEM;
+
+	ir->raw->input_dev = input_dev;
+	INIT_WORK(&ir->raw->rx_work, ir_raw_event_work);
+	ir->raw->enabled_protocols = ~0;
+	rc = kfifo_alloc(&ir->raw->kfifo, sizeof(s64) * MAX_IR_EVENT_SIZE,
+			 GFP_KERNEL);
+	if (rc < 0) {
+		kfree(ir->raw);
+		ir->raw = NULL;
+		return rc;
+	}
+
+	rc = RUN_DECODER(raw_register, input_dev);
+	if (rc < 0) {
+		kfifo_free(&ir->raw->kfifo);
+		kfree(ir->raw);
+		ir->raw = NULL;
+		return rc;
+	}
+
+	return rc;
+}
+
+void ir_raw_event_unregister(struct input_dev *input_dev)
+{
+	struct ir_input_dev *ir = input_get_drvdata(input_dev);
+
+	if (!ir->raw)
+		return;
+
+	cancel_work_sync(&ir->raw->rx_work);
+	RUN_DECODER(raw_unregister, input_dev);
+
+	kfifo_free(&ir->raw->kfifo);
+	kfree(ir->raw);
+	ir->raw = NULL;
+}
+
 /*
  * Extension interface - used to register the IR decoders
  */
@@ -212,7 +227,9 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler)
 {
 	spin_lock(&ir_raw_handler_lock);
 	list_add_tail(&ir_raw_handler->list, &ir_raw_handler_list);
+	available_protocols |= ir_raw_handler->protocols;
 	spin_unlock(&ir_raw_handler_lock);
+
 	return 0;
 }
 EXPORT_SYMBOL(ir_raw_handler_register);
@@ -221,6 +238,7 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)
 {
 	spin_lock(&ir_raw_handler_lock);
 	list_del(&ir_raw_handler->list);
+	available_protocols &= ~ir_raw_handler->protocols;
 	spin_unlock(&ir_raw_handler_lock);
 }
 EXPORT_SYMBOL(ir_raw_handler_unregister);
diff --git a/drivers/media/IR/ir-rc5-decoder.c b/drivers/media/IR/ir-rc5-decoder.c
index 23cdb1b..1be8981 100644
--- a/drivers/media/IR/ir-rc5-decoder.c
+++ b/drivers/media/IR/ir-rc5-decoder.c
@@ -45,7 +45,6 @@ enum rc5_state {
 struct decoder_data {
 	struct list_head	list;
 	struct ir_input_dev	*ir_dev;
-	int			enabled:1;
 
 	/* State machine control */
 	enum rc5_state		state;
@@ -76,53 +75,6 @@ static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
 	return data;
 }
 
-static ssize_t store_enabled(struct device *d,
-			     struct device_attribute *mattr,
-			     const char *buf,
-			     size_t len)
-{
-	unsigned long value;
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (strict_strtoul(buf, 10, &value) || value > 1)
-		return -EINVAL;
-
-	data->enabled = value;
-
-	return len;
-}
-
-static ssize_t show_enabled(struct device *d,
-			     struct device_attribute *mattr, char *buf)
-{
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (data->enabled)
-		return sprintf(buf, "1\n");
-	else
-	return sprintf(buf, "0\n");
-}
-
-static DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR, show_enabled, store_enabled);
-
-static struct attribute *decoder_attributes[] = {
-	&dev_attr_enabled.attr,
-	NULL
-};
-
-static struct attribute_group decoder_attribute_group = {
-	.name	= "rc5_decoder",
-	.attrs	= decoder_attributes,
-};
-
 /**
  * ir_rc5_decode() - Decode one RC-5 pulse or space
  * @input_dev:	the struct input_dev descriptor of the device
@@ -141,7 +93,7 @@ static int ir_rc5_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 	if (!data)
 		return -EINVAL;
 
-	if (!data->enabled)
+	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_RC5))
 		return 0;
 
 	if (IS_RESET(ev)) {
@@ -256,21 +208,12 @@ static int ir_rc5_register(struct input_dev *input_dev)
 {
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
 	struct decoder_data *data;
-	int rc;
-
-	rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-	if (rc < 0)
-		return rc;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
+	if (!data)
 		return -ENOMEM;
-	}
 
 	data->ir_dev = ir_dev;
-	data->enabled = 1;
-
 	spin_lock(&decoder_lock);
 	list_add_tail(&data->list, &decoder_list);
 	spin_unlock(&decoder_lock);
@@ -287,8 +230,6 @@ static int ir_rc5_unregister(struct input_dev *input_dev)
 	if (!data)
 		return 0;
 
-	sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-
 	spin_lock(&decoder_lock);
 	list_del(&data->list);
 	spin_unlock(&decoder_lock);
@@ -297,6 +238,7 @@ static int ir_rc5_unregister(struct input_dev *input_dev)
 }
 
 static struct ir_raw_handler rc5_handler = {
+	.protocols	= IR_TYPE_RC5,
 	.decode		= ir_rc5_decode,
 	.raw_register	= ir_rc5_register,
 	.raw_unregister	= ir_rc5_unregister,
diff --git a/drivers/media/IR/ir-rc6-decoder.c b/drivers/media/IR/ir-rc6-decoder.c
index 2bf479f..5e940a8 100644
--- a/drivers/media/IR/ir-rc6-decoder.c
+++ b/drivers/media/IR/ir-rc6-decoder.c
@@ -61,7 +61,6 @@ enum rc6_state {
 struct decoder_data {
 	struct list_head	list;
 	struct ir_input_dev	*ir_dev;
-	int			enabled:1;
 
 	/* State machine control */
 	enum rc6_state		state;
@@ -93,53 +92,6 @@ static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
 	return data;
 }
 
-static ssize_t store_enabled(struct device *d,
-			     struct device_attribute *mattr,
-			     const char *buf,
-			     size_t len)
-{
-	unsigned long value;
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (strict_strtoul(buf, 10, &value) || value > 1)
-		return -EINVAL;
-
-	data->enabled = value;
-
-	return len;
-}
-
-static ssize_t show_enabled(struct device *d,
-			     struct device_attribute *mattr, char *buf)
-{
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (data->enabled)
-		return sprintf(buf, "1\n");
-	else
-	return sprintf(buf, "0\n");
-}
-
-static DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR, show_enabled, store_enabled);
-
-static struct attribute *decoder_attributes[] = {
-	&dev_attr_enabled.attr,
-	NULL
-};
-
-static struct attribute_group decoder_attribute_group = {
-	.name	= "rc6_decoder",
-	.attrs	= decoder_attributes,
-};
-
 static enum rc6_mode rc6_mode(struct decoder_data *data) {
 	switch (data->header & RC6_MODE_MASK) {
 	case 0:
@@ -171,7 +123,7 @@ static int ir_rc6_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 	if (!data)
 		return -EINVAL;
 
-	if (!data->enabled)
+	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_RC6))
 		return 0;
 
 	if (IS_RESET(ev)) {
@@ -352,21 +304,12 @@ static int ir_rc6_register(struct input_dev *input_dev)
 {
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
 	struct decoder_data *data;
-	int rc;
-
-	rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-	if (rc < 0)
-		return rc;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
+	if (!data)
 		return -ENOMEM;
-	}
 
 	data->ir_dev = ir_dev;
-	data->enabled = 1;
-
 	spin_lock(&decoder_lock);
 	list_add_tail(&data->list, &decoder_list);
 	spin_unlock(&decoder_lock);
@@ -383,8 +326,6 @@ static int ir_rc6_unregister(struct input_dev *input_dev)
 	if (!data)
 		return 0;
 
-	sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-
 	spin_lock(&decoder_lock);
 	list_del(&data->list);
 	spin_unlock(&decoder_lock);
@@ -393,6 +334,7 @@ static int ir_rc6_unregister(struct input_dev *input_dev)
 }
 
 static struct ir_raw_handler rc6_handler = {
+	.protocols	= IR_TYPE_RC6,
 	.decode		= ir_rc6_decode,
 	.raw_register	= ir_rc6_register,
 	.raw_unregister	= ir_rc6_unregister,
diff --git a/drivers/media/IR/ir-sony-decoder.c b/drivers/media/IR/ir-sony-decoder.c
index 9f440c5..8afd16a 100644
--- a/drivers/media/IR/ir-sony-decoder.c
+++ b/drivers/media/IR/ir-sony-decoder.c
@@ -38,7 +38,6 @@ enum sony_state {
 struct decoder_data {
 	struct list_head	list;
 	struct ir_input_dev	*ir_dev;
-	int			enabled:1;
 
 	/* State machine control */
 	enum sony_state		state;
@@ -66,53 +65,6 @@ static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
 	return data;
 }
 
-static ssize_t store_enabled(struct device *d,
-			     struct device_attribute *mattr,
-			     const char *buf,
-			     size_t len)
-{
-	unsigned long value;
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (strict_strtoul(buf, 10, &value) || value > 1)
-		return -EINVAL;
-
-	data->enabled = value;
-
-	return len;
-}
-
-static ssize_t show_enabled(struct device *d,
-			     struct device_attribute *mattr, char *buf)
-{
-	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	struct decoder_data *data = get_decoder_data(ir_dev);
-
-	if (!data)
-		return -EINVAL;
-
-	if (data->enabled)
-		return sprintf(buf, "1\n");
-	else
-	return sprintf(buf, "0\n");
-}
-
-static DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR, show_enabled, store_enabled);
-
-static struct attribute *decoder_attributes[] = {
-	&dev_attr_enabled.attr,
-	NULL
-};
-
-static struct attribute_group decoder_attribute_group = {
-	.name	= "sony_decoder",
-	.attrs	= decoder_attributes,
-};
-
 /**
  * ir_sony_decode() - Decode one Sony pulse or space
  * @input_dev:	the struct input_dev descriptor of the device
@@ -131,7 +83,7 @@ static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 	if (!data)
 		return -EINVAL;
 
-	if (!data->enabled)
+	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_SONY))
 		return 0;
 
 	if (IS_RESET(ev)) {
@@ -245,21 +197,12 @@ static int ir_sony_register(struct input_dev *input_dev)
 {
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
 	struct decoder_data *data;
-	int rc;
-
-	rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-	if (rc < 0)
-		return rc;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
+	if (!data)
 		return -ENOMEM;
-	}
 
 	data->ir_dev = ir_dev;
-	data->enabled = 1;
-
 	spin_lock(&decoder_lock);
 	list_add_tail(&data->list, &decoder_list);
 	spin_unlock(&decoder_lock);
@@ -276,8 +219,6 @@ static int ir_sony_unregister(struct input_dev *input_dev)
 	if (!data)
 		return 0;
 
-	sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group);
-
 	spin_lock(&decoder_lock);
 	list_del(&data->list);
 	spin_unlock(&decoder_lock);
@@ -286,6 +227,7 @@ static int ir_sony_unregister(struct input_dev *input_dev)
 }
 
 static struct ir_raw_handler sony_handler = {
+	.protocols	= IR_TYPE_SONY,
 	.decode		= ir_sony_decode,
 	.raw_register	= ir_sony_register,
 	.raw_unregister	= ir_sony_unregister,
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index daf33c1..7ae5662 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -33,122 +33,178 @@ static struct class ir_input_class = {
 };
 
 /**
- * show_protocol() - shows the current IR protocol
+ * show_protocols() - shows the current IR protocol(s)
  * @d:		the device descriptor
  * @mattr:	the device attribute struct (unused)
  * @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/rc?/current_protocol.
- * It returns the protocol name, as understood by the driver.
+ * This routine is a callback routine for input read the IR protocol type(s).
+ * it is trigged by reading /sys/class/rc/rc?/protocols.
+ * It returns the protocol names of supported protocols.
+ * Enabled protocols are printed in brackets.
  */
-static ssize_t show_protocol(struct device *d,
-			     struct device_attribute *mattr, char *buf)
+static ssize_t show_protocols(struct device *d,
+			      struct device_attribute *mattr, char *buf)
 {
-	char *s;
 	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	u64 ir_type = ir_dev->rc_tab.ir_type;
-
-	IR_dprintk(1, "Current protocol is %lld\n", (long long)ir_type);
-
-	/* FIXME: doesn't support multiple protocols at the same time */
-	if (ir_type == IR_TYPE_UNKNOWN)
-		s = "Unknown";
-	else if (ir_type == IR_TYPE_RC5)
-		s = "rc-5";
-	else if (ir_type == IR_TYPE_NEC)
-		s = "nec";
-	else if (ir_type == IR_TYPE_RC6)
-		s = "rc6";
-	else if (ir_type == IR_TYPE_JVC)
-		s = "jvc";
-	else if (ir_type == IR_TYPE_SONY)
-		s = "sony";
-	else
-		s = "other";
+	u64 allowed, enabled;
+	char *tmp = buf;
+
+	if (ir_dev->props->driver_type == RC_DRIVER_SCANCODE) {
+		enabled = ir_dev->rc_tab.ir_type;
+		allowed = ir_dev->props->allowed_protos;
+	} else {
+		enabled = ir_dev->raw->enabled_protocols;
+		allowed = ir_raw_get_allowed_protocols();
+	}
 
-	return sprintf(buf, "%s\n", s);
+	IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n",
+		   (long long)allowed,
+		   (long long)enabled);
+
+	if (allowed & enabled & IR_TYPE_UNKNOWN)
+		tmp += sprintf(tmp, "[unknown] ");
+	else if (allowed & IR_TYPE_UNKNOWN)
+		tmp += sprintf(tmp, "unknown ");
+
+	if (allowed & enabled & IR_TYPE_RC5)
+		tmp += sprintf(tmp, "[rc5] ");
+	else if (allowed & IR_TYPE_RC5)
+		tmp += sprintf(tmp, "rc5 ");
+
+	if (allowed & enabled & IR_TYPE_NEC)
+		tmp += sprintf(tmp, "[nec] ");
+	else if (allowed & IR_TYPE_NEC)
+		tmp += sprintf(tmp, "nec ");
+
+	if (allowed & enabled & IR_TYPE_RC6)
+		tmp += sprintf(tmp, "[rc6] ");
+	else if (allowed & IR_TYPE_RC6)
+		tmp += sprintf(tmp, "rc6 ");
+
+	if (allowed & enabled & IR_TYPE_JVC)
+		tmp += sprintf(tmp, "[jvc] ");
+	else if (allowed & IR_TYPE_JVC)
+		tmp += sprintf(tmp, "jvc ");
+
+	if (allowed & enabled & IR_TYPE_SONY)
+		tmp += sprintf(tmp, "[sony] ");
+	else if (allowed & IR_TYPE_SONY)
+		tmp += sprintf(tmp, "sony ");
+
+	if (tmp != buf)
+		tmp--;
+	*tmp = '\n';
+	return tmp + 1 - buf;
 }
 
 /**
- * store_protocol() - shows the current IR protocol
+ * store_protocols() - changes the current IR protocol(s)
  * @d:		the device descriptor
  * @mattr:	the device attribute struct (unused)
  * @buf:	a pointer to the input buffer
  * @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/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.
+ * It is trigged by writing to /sys/class/rc/rc?/protocols.
+ * Writing "+proto" will add a protocol to the list of enabled protocols.
+ * Writing "-proto" will remove a protocol from the list of enabled protocols.
+ * Writing "proto" will enable only "proto".
+ * Returns -EINVAL if an invalid protocol combination or unknown protocol name
+ * is used, otherwise @len.
  */
-static ssize_t store_protocol(struct device *d,
-			      struct device_attribute *mattr,
-			      const char *data,
-			      size_t len)
+static ssize_t store_protocols(struct device *d,
+			       struct device_attribute *mattr,
+			       const char *data,
+			       size_t len)
 {
 	struct ir_input_dev *ir_dev = dev_get_drvdata(d);
-	u64 ir_type = 0;
-	int rc = -EINVAL;
+	bool enable, disable;
+	const char *tmp;
+	u64 type;
+	u64 mask;
+	int rc;
 	unsigned long flags;
-	char *buf;
-
-	while ((buf = strsep((char **) &data, " \n")) != NULL) {
-		if (!strcasecmp(buf, "rc-5") || !strcasecmp(buf, "rc5"))
-			ir_type |= IR_TYPE_RC5;
-		if (!strcasecmp(buf, "nec"))
-			ir_type |= IR_TYPE_NEC;
-		if (!strcasecmp(buf, "jvc"))
-			ir_type |= IR_TYPE_JVC;
-		if (!strcasecmp(buf, "sony"))
-			ir_type |= IR_TYPE_SONY;
+
+	tmp = skip_spaces(data);
+
+	if (*tmp == '+') {
+		enable = true;
+		disable = false;
+		tmp++;
+	} else if (*tmp == '-') {
+		enable = false;
+		disable = true;
+		tmp++;
+	} else {
+		enable = false;
+		disable = false;
 	}
 
-	if (!ir_type) {
+	if (!strncasecmp(tmp, "unknown", 7)) {
+		tmp += 7;
+		mask = IR_TYPE_UNKNOWN;
+	} else if (!strncasecmp(tmp, "rc5", 3)) {
+		tmp += 3;
+		mask = IR_TYPE_RC5;
+	} else if (!strncasecmp(tmp, "nec", 3)) {
+		tmp += 3;
+		mask = IR_TYPE_NEC;
+	} else if (!strncasecmp(tmp, "rc6", 3)) {
+		tmp += 3;
+		mask = IR_TYPE_RC6;
+	} else if (!strncasecmp(tmp, "jvc", 3)) {
+		tmp += 3;
+		mask = IR_TYPE_JVC;
+	} else if (!strncasecmp(tmp, "sony", 4)) {
+		tmp += 4;
+		mask = IR_TYPE_SONY;
+	} else {
 		IR_dprintk(1, "Unknown protocol\n");
 		return -EINVAL;
 	}
 
-	if (ir_dev->props && ir_dev->props->change_protocol)
-		rc = ir_dev->props->change_protocol(ir_dev->props->priv,
-						    ir_type);
-
-	if (rc < 0) {
-		IR_dprintk(1, "Error setting protocol to %lld\n",
-			   (long long)ir_type);
+	tmp = skip_spaces(tmp);
+	if (*tmp != '\0') {
+		IR_dprintk(1, "Invalid trailing characters\n");
 		return -EINVAL;
 	}
 
-	spin_lock_irqsave(&ir_dev->rc_tab.lock, flags);
-	ir_dev->rc_tab.ir_type = ir_type;
-	spin_unlock_irqrestore(&ir_dev->rc_tab.lock, flags);
+	if (ir_dev->props->driver_type == RC_DRIVER_SCANCODE)
+		type = ir_dev->rc_tab.ir_type;
+	else
+		type = ir_dev->raw->enabled_protocols;
 
-	IR_dprintk(1, "Current protocol(s) is(are) %lld\n",
-		   (long long)ir_type);
+	if (enable)
+		type |= mask;
+	else if (disable)
+		type &= ~mask;
+	else
+		type = mask;
 
-	return len;
-}
+	if (ir_dev->props && ir_dev->props->change_protocol) {
+		rc = ir_dev->props->change_protocol(ir_dev->props->priv,
+						    type);
+		if (rc < 0) {
+			IR_dprintk(1, "Error setting protocols to 0x%llx\n",
+				   (long long)type);
+			return -EINVAL;
+		}
+	}
 
-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);
+	if (ir_dev->props->driver_type == RC_DRIVER_SCANCODE) {
+		spin_lock_irqsave(&ir_dev->rc_tab.lock, flags);
+		ir_dev->rc_tab.ir_type = type;
+		spin_unlock_irqrestore(&ir_dev->rc_tab.lock, flags);
+	} else {
+		ir_dev->raw->enabled_protocols = type;
+	}
 
-	/* 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_NEC)
-		buf += sprintf(buf, "nec ");
-	if (buf == orgbuf)
-		buf += sprintf(buf, "other ");
 
-	buf += sprintf(buf - 1, "\n");
+	IR_dprintk(1, "Current protocol(s): 0x%llx\n",
+		   (long long)type);
 
-	return buf - orgbuf;
+	return len;
 }
 
 #define ADD_HOTPLUG_VAR(fmt, val...)					\
@@ -158,7 +214,7 @@ static ssize_t show_supported_protocols(struct device *d,
 			return err;					\
 	} while (0)
 
-static int ir_dev_uevent(struct device *device, struct kobj_uevent_env *env)
+static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env)
 {
 	struct ir_input_dev *ir_dev = dev_get_drvdata(device);
 
@@ -173,34 +229,26 @@ 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(protocol, S_IRUGO | S_IWUSR,
-		   show_protocol, store_protocol);
+static DEVICE_ATTR(protocols, S_IRUGO | S_IWUSR,
+		   show_protocols, store_protocols);
 
-static DEVICE_ATTR(supported_protocols, S_IRUGO | S_IWUSR,
-		   show_supported_protocols, NULL);
-
-static struct attribute *ir_hw_dev_attrs[] = {
-	&dev_attr_protocol.attr,
-	&dev_attr_supported_protocols.attr,
+static struct attribute *rc_dev_attrs[] = {
+	&dev_attr_protocols.attr,
 	NULL,
 };
 
-static struct attribute_group ir_hw_dev_attr_grp = {
-	.attrs	= ir_hw_dev_attrs,
+static struct attribute_group rc_dev_attr_grp = {
+	.attrs	= rc_dev_attrs,
 };
 
-static const struct attribute_group *ir_hw_dev_attr_groups[] = {
-	&ir_hw_dev_attr_grp,
+static const struct attribute_group *rc_dev_attr_groups[] = {
+	&rc_dev_attr_grp,
 	NULL
 };
 
 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,
+	.groups		= rc_dev_attr_groups,
+	.uevent		= rc_dev_uevent,
 };
 
 /**
@@ -220,11 +268,7 @@ int ir_register_class(struct input_dev *input_dev)
 	if (unlikely(devno < 0))
 		return devno;
 
-	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.type = &rc_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);


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 7/8] ir-core: move decoding state to ir_raw_event_ctrl
  2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
                   ` (5 preceding siblings ...)
  2010-06-07 19:32 ` [PATCH 6/8] ir-core: centralize sysfs raw decoder enabling/disabling David Härdeman
@ 2010-06-07 19:32 ` David Härdeman
  2010-06-07 19:32 ` [PATCH 8/8] ir-core: merge rc-map.h into ir-core.h David Härdeman
  7 siblings, 0 replies; 20+ messages in thread
From: David Härdeman @ 2010-06-07 19:32 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media

This patch moves the state from each raw decoder into the
ir_raw_event_ctrl struct.

This allows the removal of code like this:

        spin_lock(&decoder_lock);
        list_for_each_entry(data, &decoder_list, list) {
                if (data->ir_dev == ir_dev)
                        break;
        }
        spin_unlock(&decoder_lock);
        return data;

which is currently run for each decoder on each event in order
to get the client-specific decoding state data.

In addition, ir decoding modules and ir driver module load
order is now independent. Centralizing the data also allows
for a nice code reduction of about 30% per raw decoder as
client lists and client registration callbacks are no longer
necessary.

Out-of-tree modules can still use a similar trick to what
the raw decoders did before this patch until they are merged.

Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/media/IR/ir-core-priv.h    |   37 ++++++++++++-
 drivers/media/IR/ir-jvc-decoder.c  |   90 ++-----------------------------
 drivers/media/IR/ir-nec-decoder.c  |   89 +++----------------------------
 drivers/media/IR/ir-raw-event.c    |   48 +++--------------
 drivers/media/IR/ir-rc5-decoder.c  |  103 +++++-------------------------------
 drivers/media/IR/ir-rc6-decoder.c  |   92 ++------------------------------
 drivers/media/IR/ir-sony-decoder.c |   93 +++------------------------------
 7 files changed, 87 insertions(+), 465 deletions(-)

diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index 3072e55..d19d819 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -23,8 +23,6 @@ struct ir_raw_handler {
 
 	u64 protocols; /* which are handled by this handler */
 	int (*decode)(struct input_dev *input_dev, struct ir_raw_event event);
-	int (*raw_register)(struct input_dev *input_dev);
-	int (*raw_unregister)(struct input_dev *input_dev);
 };
 
 struct ir_raw_event_ctrl {
@@ -34,6 +32,41 @@ struct ir_raw_event_ctrl {
 	enum raw_event_type		last_type;	/* last event type */
 	struct input_dev		*input_dev;	/* pointer to the parent input_dev */
 	u64				enabled_protocols; /* enabled raw protocol decoders */
+
+	/* raw decoder state follows */
+	struct ir_raw_event prev_ev;
+	struct nec_dec {
+		int state;
+		unsigned count;
+		u32 bits;
+	} nec;
+	struct rc5_dec {
+		int state;
+		u32 bits;
+		unsigned count;
+		unsigned wanted_bits;
+	} rc5;
+	struct rc6_dec {
+		int state;
+		u8 header;
+		u32 body;
+		bool toggle;
+		unsigned count;
+		unsigned wanted_bits;
+	} rc6;
+	struct sony_dec {
+		int state;
+		u32 bits;
+		unsigned count;
+	} sony;
+	struct jvc_dec {
+		int state;
+		u16 bits;
+		u16 old_bits;
+		unsigned count;
+		bool first;
+		bool toggle;
+	} jvc;
 };
 
 /* macros for IR decoders */
diff --git a/drivers/media/IR/ir-jvc-decoder.c b/drivers/media/IR/ir-jvc-decoder.c
index 1055de4..8894d8b 100644
--- a/drivers/media/IR/ir-jvc-decoder.c
+++ b/drivers/media/IR/ir-jvc-decoder.c
@@ -25,10 +25,6 @@
 #define JVC_TRAILER_PULSE	(1  * JVC_UNIT)
 #define	JVC_TRAILER_SPACE	(35 * JVC_UNIT)
 
-/* Used to register jvc_decoder clients */
-static LIST_HEAD(decoder_list);
-DEFINE_SPINLOCK(decoder_lock);
-
 enum jvc_state {
 	STATE_INACTIVE,
 	STATE_HEADER_SPACE,
@@ -38,39 +34,6 @@ enum jvc_state {
 	STATE_TRAILER_SPACE,
 };
 
-struct decoder_data {
-	struct list_head	list;
-	struct ir_input_dev	*ir_dev;
-
-	/* State machine control */
-	enum jvc_state		state;
-	u16			jvc_bits;
-	u16			jvc_old_bits;
-	unsigned		count;
-	bool			first;
-	bool			toggle;
-};
-
-
-/**
- * get_decoder_data()	- gets decoder data
- * @input_dev:	input device
- *
- * 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;
-
-	spin_lock(&decoder_lock);
-	list_for_each_entry(data, &decoder_list, list) {
-		if (data->ir_dev == ir_dev)
-			break;
-	}
-	spin_unlock(&decoder_lock);
-	return data;
-}
-
 /**
  * ir_jvc_decode() - Decode one JVC pulse or space
  * @input_dev:	the struct input_dev descriptor of the device
@@ -80,12 +43,8 @@ static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
  */
 static int ir_jvc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 {
-	struct decoder_data *data;
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return -EINVAL;
+	struct jvc_dec *data = &ir_dev->raw->jvc;
 
 	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_JVC))
 		return 0;
@@ -140,9 +99,9 @@ static int ir_jvc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 		if (ev.pulse)
 			break;
 
-		data->jvc_bits <<= 1;
+		data->bits <<= 1;
 		if (eq_margin(ev.duration, JVC_BIT_1_SPACE, JVC_UNIT / 2)) {
-			data->jvc_bits |= 1;
+			data->bits |= 1;
 			decrease_duration(&ev, JVC_BIT_1_SPACE);
 		} else if (eq_margin(ev.duration, JVC_BIT_0_SPACE, JVC_UNIT / 2))
 			decrease_duration(&ev, JVC_BIT_0_SPACE);
@@ -175,13 +134,13 @@ static int ir_jvc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 
 		if (data->first) {
 			u32 scancode;
-			scancode = (bitrev8((data->jvc_bits >> 8) & 0xff) << 8) |
-				   (bitrev8((data->jvc_bits >> 0) & 0xff) << 0);
+			scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) |
+				   (bitrev8((data->bits >> 0) & 0xff) << 0);
 			IR_dprintk(1, "JVC scancode 0x%04x\n", scancode);
 			ir_keydown(input_dev, scancode, data->toggle);
 			data->first = false;
-			data->jvc_old_bits = data->jvc_bits;
-		} else if (data->jvc_bits == data->jvc_old_bits) {
+			data->old_bits = data->bits;
+		} else if (data->bits == data->old_bits) {
 			IR_dprintk(1, "JVC repeat\n");
 			ir_repeat(input_dev);
 		} else {
@@ -201,44 +160,9 @@ out:
 	return -EINVAL;
 }
 
-static int ir_jvc_register(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	struct decoder_data *data;
-
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	data->ir_dev = ir_dev;
-	spin_lock(&decoder_lock);
-	list_add_tail(&data->list, &decoder_list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
-static int ir_jvc_unregister(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	static struct decoder_data *data;
-
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return 0;
-
-	spin_lock(&decoder_lock);
-	list_del(&data->list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
 static struct ir_raw_handler jvc_handler = {
 	.protocols	= IR_TYPE_JVC,
 	.decode		= ir_jvc_decode,
-	.raw_register	= ir_jvc_register,
-	.raw_unregister	= ir_jvc_unregister,
 };
 
 static int __init ir_jvc_decode_init(void)
diff --git a/drivers/media/IR/ir-nec-decoder.c b/drivers/media/IR/ir-nec-decoder.c
index 2cc2b92..52e0f37 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -27,10 +27,6 @@
 #define	NEC_TRAILER_PULSE	(1  * NEC_UNIT)
 #define	NEC_TRAILER_SPACE	(10 * NEC_UNIT) /* even longer in reality */
 
-/* Used to register nec_decoder clients */
-static LIST_HEAD(decoder_list);
-static DEFINE_SPINLOCK(decoder_lock);
-
 enum nec_state {
 	STATE_INACTIVE,
 	STATE_HEADER_SPACE,
@@ -40,36 +36,6 @@ enum nec_state {
 	STATE_TRAILER_SPACE,
 };
 
-struct decoder_data {
-	struct list_head	list;
-	struct ir_input_dev	*ir_dev;
-
-	/* State machine control */
-	enum nec_state		state;
-	u32			nec_bits;
-	unsigned		count;
-};
-
-
-/**
- * get_decoder_data()	- gets decoder data
- * @input_dev:	input device
- *
- * 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;
-
-	spin_lock(&decoder_lock);
-	list_for_each_entry(data, &decoder_list, list) {
-		if (data->ir_dev == ir_dev)
-			break;
-	}
-	spin_unlock(&decoder_lock);
-	return data;
-}
-
 /**
  * ir_nec_decode() - Decode one NEC pulse or space
  * @input_dev:	the struct input_dev descriptor of the device
@@ -79,15 +45,11 @@ static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
  */
 static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 {
-	struct decoder_data *data;
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
+	struct nec_dec *data = &ir_dev->raw->nec;
 	u32 scancode;
 	u8 address, not_address, command, not_command;
 
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return -EINVAL;
-
 	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_NEC))
 		return 0;
 
@@ -143,9 +105,9 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 		if (ev.pulse)
 			break;
 
-		data->nec_bits <<= 1;
+		data->bits <<= 1;
 		if (eq_margin(ev.duration, NEC_BIT_1_SPACE, NEC_UNIT / 2))
-			data->nec_bits |= 1;
+			data->bits |= 1;
 		else if (!eq_margin(ev.duration, NEC_BIT_0_SPACE, NEC_UNIT / 2))
 			break;
 		data->count++;
@@ -174,14 +136,14 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 		if (!geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2))
 			break;
 
-		address     = bitrev8((data->nec_bits >> 24) & 0xff);
-		not_address = bitrev8((data->nec_bits >> 16) & 0xff);
-		command	    = bitrev8((data->nec_bits >>  8) & 0xff);
-		not_command = bitrev8((data->nec_bits >>  0) & 0xff);
+		address     = bitrev8((data->bits >> 24) & 0xff);
+		not_address = bitrev8((data->bits >> 16) & 0xff);
+		command	    = bitrev8((data->bits >>  8) & 0xff);
+		not_command = bitrev8((data->bits >>  0) & 0xff);
 
 		if ((command ^ not_command) != 0xff) {
 			IR_dprintk(1, "NEC checksum error: received 0x%08x\n",
-				   data->nec_bits);
+				   data->bits);
 			break;
 		}
 
@@ -208,44 +170,9 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 	return -EINVAL;
 }
 
-static int ir_nec_register(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	struct decoder_data *data;
-
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	data->ir_dev = ir_dev;
-	spin_lock(&decoder_lock);
-	list_add_tail(&data->list, &decoder_list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
-static int ir_nec_unregister(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	static struct decoder_data *data;
-
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return 0;
-
-	spin_lock(&decoder_lock);
-	list_del(&data->list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
 static struct ir_raw_handler nec_handler = {
 	.protocols	= IR_TYPE_NEC,
 	.decode		= ir_nec_decode,
-	.raw_register	= ir_nec_register,
-	.raw_unregister	= ir_nec_unregister,
 };
 
 static int __init ir_nec_decode_init(void)
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c
index eeca8a8..eb77378 100644
--- a/drivers/media/IR/ir-raw-event.c
+++ b/drivers/media/IR/ir-raw-event.c
@@ -25,32 +25,6 @@ static DEFINE_SPINLOCK(ir_raw_handler_lock);
 static LIST_HEAD(ir_raw_handler_list);
 static u64 available_protocols;
 
-/**
- * RUN_DECODER()	- runs an operation on all IR decoders
- * @ops:	IR raw handler operation to be called
- * @arg:	arguments to be passed to the callback
- *
- * Calls ir_raw_handler::ops for all registered IR handlers. It prevents
- * new decode addition/removal while running, by locking ir_raw_handler_lock
- * mutex. If an error occurs, it stops the ops. Otherwise, it returns a sum
- * of the return codes.
- */
-#define RUN_DECODER(ops, ...) ({					    \
-	struct ir_raw_handler		*_ir_raw_handler;		    \
-	int _sumrc = 0, _rc;						    \
-	spin_lock(&ir_raw_handler_lock);				    \
-	list_for_each_entry(_ir_raw_handler, &ir_raw_handler_list, list) {  \
-		if (_ir_raw_handler->ops) {				    \
-			_rc = _ir_raw_handler->ops(__VA_ARGS__);	    \
-			if (_rc < 0)					    \
-				break;					    \
-			_sumrc += _rc;					    \
-		}							    \
-	}								    \
-	spin_unlock(&ir_raw_handler_lock);				    \
-	_sumrc;								    \
-})
-
 #ifdef MODULE
 /* Used to load the decoders */
 static struct work_struct wq_load;
@@ -59,11 +33,17 @@ static struct work_struct wq_load;
 static void ir_raw_event_work(struct work_struct *work)
 {
 	struct ir_raw_event ev;
+	struct ir_raw_handler *handler;
 	struct ir_raw_event_ctrl *raw =
 		container_of(work, struct ir_raw_event_ctrl, rx_work);
 
-	while (kfifo_out(&raw->kfifo, &ev, sizeof(ev)) == sizeof(ev))
-		RUN_DECODER(decode, raw->input_dev, ev);
+	while (kfifo_out(&raw->kfifo, &ev, sizeof(ev)) == sizeof(ev)) {
+		spin_lock(&ir_raw_handler_lock);
+		list_for_each_entry(handler, &ir_raw_handler_list, list)
+			handler->decode(raw->input_dev, ev);
+		spin_unlock(&ir_raw_handler_lock);
+		raw->prev_ev = ev;
+	}
 }
 
 /**
@@ -193,15 +173,7 @@ int ir_raw_event_register(struct input_dev *input_dev)
 		return rc;
 	}
 
-	rc = RUN_DECODER(raw_register, input_dev);
-	if (rc < 0) {
-		kfifo_free(&ir->raw->kfifo);
-		kfree(ir->raw);
-		ir->raw = NULL;
-		return rc;
-	}
-
-	return rc;
+	return 0;
 }
 
 void ir_raw_event_unregister(struct input_dev *input_dev)
@@ -212,8 +184,6 @@ void ir_raw_event_unregister(struct input_dev *input_dev)
 		return;
 
 	cancel_work_sync(&ir->raw->rx_work);
-	RUN_DECODER(raw_unregister, input_dev);
-
 	kfifo_free(&ir->raw->kfifo);
 	kfree(ir->raw);
 	ir->raw = NULL;
diff --git a/drivers/media/IR/ir-rc5-decoder.c b/drivers/media/IR/ir-rc5-decoder.c
index 1be8981..7af656d 100644
--- a/drivers/media/IR/ir-rc5-decoder.c
+++ b/drivers/media/IR/ir-rc5-decoder.c
@@ -30,10 +30,6 @@
 #define RC5_BIT_END		(1 * RC5_UNIT)
 #define RC5X_SPACE		(4 * RC5_UNIT)
 
-/* Used to register rc5_decoder clients */
-static LIST_HEAD(decoder_list);
-static DEFINE_SPINLOCK(decoder_lock);
-
 enum rc5_state {
 	STATE_INACTIVE,
 	STATE_BIT_START,
@@ -42,39 +38,6 @@ enum rc5_state {
 	STATE_FINISHED,
 };
 
-struct decoder_data {
-	struct list_head	list;
-	struct ir_input_dev	*ir_dev;
-
-	/* State machine control */
-	enum rc5_state		state;
-	u32			rc5_bits;
-	struct ir_raw_event	prev_ev;
-	unsigned		count;
-	unsigned		wanted_bits;
-};
-
-
-/**
- * get_decoder_data()	- gets decoder data
- * @input_dev:	input device
- *
- * 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;
-
-	spin_lock(&decoder_lock);
-	list_for_each_entry(data, &decoder_list, list) {
-		if (data->ir_dev == ir_dev)
-			break;
-	}
-	spin_unlock(&decoder_lock);
-	return data;
-}
-
 /**
  * ir_rc5_decode() - Decode one RC-5 pulse or space
  * @input_dev:	the struct input_dev descriptor of the device
@@ -84,15 +47,11 @@ static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
  */
 static int ir_rc5_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 {
-	struct decoder_data *data;
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
+	struct rc5_dec *data = &ir_dev->raw->rc5;
 	u8 toggle;
 	u32 scancode;
 
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return -EINVAL;
-
 	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_RC5))
 		return 0;
 
@@ -128,16 +87,15 @@ again:
 		if (!eq_margin(ev.duration, RC5_BIT_START, RC5_UNIT / 2))
 			break;
 
-		data->rc5_bits <<= 1;
+		data->bits <<= 1;
 		if (!ev.pulse)
-			data->rc5_bits |= 1;
+			data->bits |= 1;
 		data->count++;
-		data->prev_ev = ev;
 		data->state = STATE_BIT_END;
 		return 0;
 
 	case STATE_BIT_END:
-		if (!is_transition(&ev, &data->prev_ev))
+		if (!is_transition(&ev, &ir_dev->raw->prev_ev))
 			break;
 
 		if (data->count == data->wanted_bits)
@@ -169,11 +127,11 @@ again:
 		if (data->wanted_bits == RC5X_NBITS) {
 			/* RC5X */
 			u8 xdata, command, system;
-			xdata    = (data->rc5_bits & 0x0003F) >> 0;
-			command  = (data->rc5_bits & 0x00FC0) >> 6;
-			system   = (data->rc5_bits & 0x1F000) >> 12;
-			toggle   = (data->rc5_bits & 0x20000) ? 1 : 0;
-			command += (data->rc5_bits & 0x01000) ? 0 : 0x40;
+			xdata    = (data->bits & 0x0003F) >> 0;
+			command  = (data->bits & 0x00FC0) >> 6;
+			system   = (data->bits & 0x1F000) >> 12;
+			toggle   = (data->bits & 0x20000) ? 1 : 0;
+			command += (data->bits & 0x01000) ? 0 : 0x40;
 			scancode = system << 16 | command << 8 | xdata;
 
 			IR_dprintk(1, "RC5X scancode 0x%06x (toggle: %u)\n",
@@ -182,10 +140,10 @@ again:
 		} else {
 			/* RC5 */
 			u8 command, system;
-			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;
+			command  = (data->bits & 0x0003F) >> 0;
+			system   = (data->bits & 0x007C0) >> 6;
+			toggle   = (data->bits & 0x00800) ? 1 : 0;
+			command += (data->bits & 0x01000) ? 0 : 0x40;
 			scancode = system << 8 | command;
 
 			IR_dprintk(1, "RC5 scancode 0x%04x (toggle: %u)\n",
@@ -204,44 +162,9 @@ out:
 	return -EINVAL;
 }
 
-static int ir_rc5_register(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	struct decoder_data *data;
-
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	data->ir_dev = ir_dev;
-	spin_lock(&decoder_lock);
-	list_add_tail(&data->list, &decoder_list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
-static int ir_rc5_unregister(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	static struct decoder_data *data;
-
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return 0;
-
-	spin_lock(&decoder_lock);
-	list_del(&data->list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
 static struct ir_raw_handler rc5_handler = {
 	.protocols	= IR_TYPE_RC5,
 	.decode		= ir_rc5_decode,
-	.raw_register	= ir_rc5_register,
-	.raw_unregister	= ir_rc5_unregister,
 };
 
 static int __init ir_rc5_decode_init(void)
diff --git a/drivers/media/IR/ir-rc6-decoder.c b/drivers/media/IR/ir-rc6-decoder.c
index 5e940a8..a562952 100644
--- a/drivers/media/IR/ir-rc6-decoder.c
+++ b/drivers/media/IR/ir-rc6-decoder.c
@@ -36,10 +36,6 @@
 #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,
@@ -58,41 +54,7 @@ enum rc6_state {
 	STATE_FINISHED,
 };
 
-struct decoder_data {
-	struct list_head	list;
-	struct ir_input_dev	*ir_dev;
-
-	/* State machine control */
-	enum rc6_state		state;
-	u8			header;
-	u32			body;
-	struct ir_raw_event	prev_ev;
-	bool			toggle;
-	unsigned		count;
-	unsigned		wanted_bits;
-};
-
-
-/**
- * get_decoder_data()	- gets decoder data
- * @input_dev:	input device
- *
- * 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;
-
-	spin_lock(&decoder_lock);
-	list_for_each_entry(data, &decoder_list, list) {
-		if (data->ir_dev == ir_dev)
-			break;
-	}
-	spin_unlock(&decoder_lock);
-	return data;
-}
-
-static enum rc6_mode rc6_mode(struct decoder_data *data) {
+static enum rc6_mode rc6_mode(struct rc6_dec *data) {
 	switch (data->header & RC6_MODE_MASK) {
 	case 0:
 		return RC6_MODE_0;
@@ -114,15 +76,11 @@ static enum rc6_mode rc6_mode(struct decoder_data *data) {
  */
 static int ir_rc6_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 {
-	struct decoder_data *data;
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
+	struct rc6_dec *data = &ir_dev->raw->rc6;
 	u32 scancode;
 	u8 toggle;
 
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return -EINVAL;
-
 	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_RC6))
 		return 0;
 
@@ -175,12 +133,11 @@ again:
 		if (ev.pulse)
 			data->header |= 1;
 		data->count++;
-		data->prev_ev = ev;
 		data->state = STATE_HEADER_BIT_END;
 		return 0;
 
 	case STATE_HEADER_BIT_END:
-		if (!is_transition(&ev, &data->prev_ev))
+		if (!is_transition(&ev, &ir_dev->raw->prev_ev))
 			break;
 
 		if (data->count == RC6_HEADER_NBITS)
@@ -196,12 +153,11 @@ again:
 			break;
 
 		data->toggle = ev.pulse;
-		data->prev_ev = ev;
 		data->state = STATE_TOGGLE_END;
 		return 0;
 
 	case STATE_TOGGLE_END:
-		if (!is_transition(&ev, &data->prev_ev) ||
+		if (!is_transition(&ev, &ir_dev->raw->prev_ev) ||
 		    !geq_margin(ev.duration, RC6_TOGGLE_END, RC6_UNIT / 2))
 			break;
 
@@ -211,7 +167,6 @@ again:
 		}
 
 		data->state = STATE_BODY_BIT_START;
-		data->prev_ev = ev;
 		decrease_duration(&ev, RC6_TOGGLE_END);
 		data->count = 0;
 
@@ -243,13 +198,11 @@ again:
 		if (ev.pulse)
 			data->body |= 1;
 		data->count++;
-		data->prev_ev = ev;
-
 		data->state = STATE_BODY_BIT_END;
 		return 0;
 
 	case STATE_BODY_BIT_END:
-		if (!is_transition(&ev, &data->prev_ev))
+		if (!is_transition(&ev, &ir_dev->raw->prev_ev))
 			break;
 
 		if (data->count == data->wanted_bits)
@@ -300,44 +253,9 @@ out:
 	return -EINVAL;
 }
 
-static int ir_rc6_register(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	struct decoder_data *data;
-
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	data->ir_dev = ir_dev;
-	spin_lock(&decoder_lock);
-	list_add_tail(&data->list, &decoder_list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
-static int ir_rc6_unregister(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	static struct decoder_data *data;
-
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return 0;
-
-	spin_lock(&decoder_lock);
-	list_del(&data->list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
 static struct ir_raw_handler rc6_handler = {
 	.protocols	= IR_TYPE_RC6,
 	.decode		= ir_rc6_decode,
-	.raw_register	= ir_rc6_register,
-	.raw_unregister	= ir_rc6_unregister,
 };
 
 static int __init ir_rc6_decode_init(void)
diff --git a/drivers/media/IR/ir-sony-decoder.c b/drivers/media/IR/ir-sony-decoder.c
index 8afd16a..b9074f0 100644
--- a/drivers/media/IR/ir-sony-decoder.c
+++ b/drivers/media/IR/ir-sony-decoder.c
@@ -23,10 +23,6 @@
 #define SONY_BIT_SPACE		(1 * SONY_UNIT)
 #define SONY_TRAILER_SPACE	(10 * SONY_UNIT) /* minimum */
 
-/* Used to register sony_decoder clients */
-static LIST_HEAD(decoder_list);
-static DEFINE_SPINLOCK(decoder_lock);
-
 enum sony_state {
 	STATE_INACTIVE,
 	STATE_HEADER_SPACE,
@@ -35,36 +31,6 @@ enum sony_state {
 	STATE_FINISHED,
 };
 
-struct decoder_data {
-	struct list_head	list;
-	struct ir_input_dev	*ir_dev;
-
-	/* State machine control */
-	enum sony_state		state;
-	u32			sony_bits;
-	unsigned		count;
-};
-
-
-/**
- * get_decoder_data()	- gets decoder data
- * @input_dev:	input device
- *
- * 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;
-
-	spin_lock(&decoder_lock);
-	list_for_each_entry(data, &decoder_list, list) {
-		if (data->ir_dev == ir_dev)
-			break;
-	}
-	spin_unlock(&decoder_lock);
-	return data;
-}
-
 /**
  * ir_sony_decode() - Decode one Sony pulse or space
  * @input_dev:	the struct input_dev descriptor of the device
@@ -74,15 +40,11 @@ static struct decoder_data *get_decoder_data(struct  ir_input_dev *ir_dev)
  */
 static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 {
-	struct decoder_data *data;
 	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
+	struct sony_dec *data = &ir_dev->raw->sony;
 	u32 scancode;
 	u8 device, subdevice, function;
 
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return -EINVAL;
-
 	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_SONY))
 		return 0;
 
@@ -124,9 +86,9 @@ static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 		if (!ev.pulse)
 			break;
 
-		data->sony_bits <<= 1;
+		data->bits <<= 1;
 		if (eq_margin(ev.duration, SONY_BIT_1_PULSE, SONY_UNIT / 2))
-			data->sony_bits |= 1;
+			data->bits |= 1;
 		else if (!eq_margin(ev.duration, SONY_BIT_0_PULSE, SONY_UNIT / 2))
 			break;
 
@@ -160,19 +122,19 @@ static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 
 		switch (data->count) {
 		case 12:
-			device    = bitrev8((data->sony_bits <<  3) & 0xF8);
+			device    = bitrev8((data->bits <<  3) & 0xF8);
 			subdevice = 0;
-			function  = bitrev8((data->sony_bits >>  4) & 0xFE);
+			function  = bitrev8((data->bits >>  4) & 0xFE);
 			break;
 		case 15:
-			device    = bitrev8((data->sony_bits >>  0) & 0xFF);
+			device    = bitrev8((data->bits >>  0) & 0xFF);
 			subdevice = 0;
-			function  = bitrev8((data->sony_bits >>  7) & 0xFD);
+			function  = bitrev8((data->bits >>  7) & 0xFD);
 			break;
 		case 20:
-			device    = bitrev8((data->sony_bits >>  5) & 0xF8);
-			subdevice = bitrev8((data->sony_bits >>  0) & 0xFF);
-			function  = bitrev8((data->sony_bits >> 12) & 0xFE);
+			device    = bitrev8((data->bits >>  5) & 0xF8);
+			subdevice = bitrev8((data->bits >>  0) & 0xFF);
+			function  = bitrev8((data->bits >> 12) & 0xFE);
 			break;
 		default:
 			IR_dprintk(1, "Sony invalid bitcount %u\n", data->count);
@@ -193,44 +155,9 @@ out:
 	return -EINVAL;
 }
 
-static int ir_sony_register(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	struct decoder_data *data;
-
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	data->ir_dev = ir_dev;
-	spin_lock(&decoder_lock);
-	list_add_tail(&data->list, &decoder_list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
-static int ir_sony_unregister(struct input_dev *input_dev)
-{
-	struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-	static struct decoder_data *data;
-
-	data = get_decoder_data(ir_dev);
-	if (!data)
-		return 0;
-
-	spin_lock(&decoder_lock);
-	list_del(&data->list);
-	spin_unlock(&decoder_lock);
-
-	return 0;
-}
-
 static struct ir_raw_handler sony_handler = {
 	.protocols	= IR_TYPE_SONY,
 	.decode		= ir_sony_decode,
-	.raw_register	= ir_sony_register,
-	.raw_unregister	= ir_sony_unregister,
 };
 
 static int __init ir_sony_decode_init(void)


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 8/8] ir-core: merge rc-map.h into ir-core.h
  2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
                   ` (6 preceding siblings ...)
  2010-06-07 19:32 ` [PATCH 7/8] ir-core: move decoding state to ir_raw_event_ctrl David Härdeman
@ 2010-06-07 19:32 ` David Härdeman
  2010-06-28 17:45   ` Mauro Carvalho Chehab
  7 siblings, 1 reply; 20+ messages in thread
From: David Härdeman @ 2010-06-07 19:32 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media

Haven't discussed this patch on the linux-media list yet, but
merging rc-map.h into ir-core.h at least makes it much easier
for me to get a good overview of the entire rc-core subsystem
(and to make sweeping changes). Not sure if everyone agrees?

Signed-off-by: David Härdeman <david@hardeman.nu>
---
 drivers/media/IR/keymaps/rc-adstech-dvb-t-pci.c    |    2 
 drivers/media/IR/keymaps/rc-apac-viewcomp.c        |    2 
 drivers/media/IR/keymaps/rc-asus-pc39.c            |    2 
 drivers/media/IR/keymaps/rc-ati-tv-wonder-hd-600.c |    2 
 drivers/media/IR/keymaps/rc-avermedia-a16d.c       |    2 
 drivers/media/IR/keymaps/rc-avermedia-cardbus.c    |    2 
 drivers/media/IR/keymaps/rc-avermedia-dvbt.c       |    2 
 .../media/IR/keymaps/rc-avermedia-m135a-rm-jx.c    |    2 
 drivers/media/IR/keymaps/rc-avermedia.c            |    2 
 drivers/media/IR/keymaps/rc-avertv-303.c           |    2 
 drivers/media/IR/keymaps/rc-behold-columbus.c      |    2 
 drivers/media/IR/keymaps/rc-behold.c               |    2 
 drivers/media/IR/keymaps/rc-budget-ci-old.c        |    2 
 drivers/media/IR/keymaps/rc-cinergy-1400.c         |    2 
 drivers/media/IR/keymaps/rc-cinergy.c              |    2 
 drivers/media/IR/keymaps/rc-dm1105-nec.c           |    2 
 drivers/media/IR/keymaps/rc-dntv-live-dvb-t.c      |    2 
 drivers/media/IR/keymaps/rc-dntv-live-dvbt-pro.c   |    2 
 drivers/media/IR/keymaps/rc-em-terratec.c          |    2 
 drivers/media/IR/keymaps/rc-empty.c                |    2 
 drivers/media/IR/keymaps/rc-encore-enltv-fm53.c    |    2 
 drivers/media/IR/keymaps/rc-encore-enltv.c         |    2 
 drivers/media/IR/keymaps/rc-encore-enltv2.c        |    2 
 drivers/media/IR/keymaps/rc-evga-indtube.c         |    2 
 drivers/media/IR/keymaps/rc-eztv.c                 |    2 
 drivers/media/IR/keymaps/rc-flydvb.c               |    2 
 drivers/media/IR/keymaps/rc-flyvideo.c             |    2 
 drivers/media/IR/keymaps/rc-fusionhdtv-mce.c       |    2 
 drivers/media/IR/keymaps/rc-gadmei-rm008z.c        |    2 
 drivers/media/IR/keymaps/rc-genius-tvgo-a11mce.c   |    2 
 drivers/media/IR/keymaps/rc-gotview7135.c          |    2 
 drivers/media/IR/keymaps/rc-hauppauge-new.c        |    2 
 drivers/media/IR/keymaps/rc-imon-mce.c             |    2 
 drivers/media/IR/keymaps/rc-imon-pad.c             |    2 
 drivers/media/IR/keymaps/rc-iodata-bctv7e.c        |    2 
 drivers/media/IR/keymaps/rc-kaiomy.c               |    2 
 drivers/media/IR/keymaps/rc-kworld-315u.c          |    2 
 .../media/IR/keymaps/rc-kworld-plus-tv-analog.c    |    2 
 drivers/media/IR/keymaps/rc-manli.c                |    2 
 drivers/media/IR/keymaps/rc-msi-tvanywhere-plus.c  |    2 
 drivers/media/IR/keymaps/rc-msi-tvanywhere.c       |    2 
 drivers/media/IR/keymaps/rc-nebula.c               |    2 
 .../media/IR/keymaps/rc-nec-terratec-cinergy-xs.c  |    2 
 drivers/media/IR/keymaps/rc-norwood.c              |    2 
 drivers/media/IR/keymaps/rc-npgtech.c              |    2 
 drivers/media/IR/keymaps/rc-pctv-sedna.c           |    2 
 drivers/media/IR/keymaps/rc-pinnacle-color.c       |    2 
 drivers/media/IR/keymaps/rc-pinnacle-grey.c        |    2 
 drivers/media/IR/keymaps/rc-pinnacle-pctv-hd.c     |    2 
 drivers/media/IR/keymaps/rc-pixelview-mk12.c       |    2 
 drivers/media/IR/keymaps/rc-pixelview-new.c        |    2 
 drivers/media/IR/keymaps/rc-pixelview.c            |    2 
 .../media/IR/keymaps/rc-powercolor-real-angel.c    |    2 
 drivers/media/IR/keymaps/rc-proteus-2309.c         |    2 
 drivers/media/IR/keymaps/rc-purpletv.c             |    2 
 drivers/media/IR/keymaps/rc-pv951.c                |    2 
 drivers/media/IR/keymaps/rc-rc5-hauppauge-new.c    |    2 
 drivers/media/IR/keymaps/rc-rc5-tv.c               |    2 
 .../media/IR/keymaps/rc-real-audio-220-32-keys.c   |    2 
 drivers/media/IR/keymaps/rc-tbs-nec.c              |    2 
 drivers/media/IR/keymaps/rc-terratec-cinergy-xs.c  |    2 
 drivers/media/IR/keymaps/rc-tevii-nec.c            |    2 
 drivers/media/IR/keymaps/rc-tt-1500.c              |    2 
 drivers/media/IR/keymaps/rc-videomate-s350.c       |    2 
 drivers/media/IR/keymaps/rc-videomate-tv-pvr.c     |    2 
 drivers/media/IR/keymaps/rc-winfast-usbii-deluxe.c |    2 
 drivers/media/IR/keymaps/rc-winfast.c              |    2 
 include/media/ir-core.h                            |  112 ++++++++++++++++++-
 include/media/rc-map.h                             |  121 --------------------
 69 files changed, 178 insertions(+), 189 deletions(-)
 delete mode 100644 include/media/rc-map.h

diff --git a/drivers/media/IR/keymaps/rc-adstech-dvb-t-pci.c b/drivers/media/IR/keymaps/rc-adstech-dvb-t-pci.c
index b172831..8d5655a 100644
--- a/drivers/media/IR/keymaps/rc-adstech-dvb-t-pci.c
+++ b/drivers/media/IR/keymaps/rc-adstech-dvb-t-pci.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* ADS Tech Instant TV DVB-T PCI Remote */
 
diff --git a/drivers/media/IR/keymaps/rc-apac-viewcomp.c b/drivers/media/IR/keymaps/rc-apac-viewcomp.c
index 0ef2b56..fa9c9a7 100644
--- a/drivers/media/IR/keymaps/rc-apac-viewcomp.c
+++ b/drivers/media/IR/keymaps/rc-apac-viewcomp.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Attila Kondoros <attila.kondoros@chello.hu> */
 
diff --git a/drivers/media/IR/keymaps/rc-asus-pc39.c b/drivers/media/IR/keymaps/rc-asus-pc39.c
index 2aa068c..d6bd983 100644
--- a/drivers/media/IR/keymaps/rc-asus-pc39.c
+++ b/drivers/media/IR/keymaps/rc-asus-pc39.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
  * Marc Fargas <telenieko@telenieko.com>
diff --git a/drivers/media/IR/keymaps/rc-ati-tv-wonder-hd-600.c b/drivers/media/IR/keymaps/rc-ati-tv-wonder-hd-600.c
index 8edfd29..cb4ddc8 100644
--- a/drivers/media/IR/keymaps/rc-ati-tv-wonder-hd-600.c
+++ b/drivers/media/IR/keymaps/rc-ati-tv-wonder-hd-600.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* ATI TV Wonder HD 600 USB
    Devin Heitmueller <devin.heitmueller@gmail.com>
diff --git a/drivers/media/IR/keymaps/rc-avermedia-a16d.c b/drivers/media/IR/keymaps/rc-avermedia-a16d.c
index 12f0435..332de38 100644
--- a/drivers/media/IR/keymaps/rc-avermedia-a16d.c
+++ b/drivers/media/IR/keymaps/rc-avermedia-a16d.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode avermedia_a16d[] = {
 	{ 0x20, KEY_LIST},
diff --git a/drivers/media/IR/keymaps/rc-avermedia-cardbus.c b/drivers/media/IR/keymaps/rc-avermedia-cardbus.c
index 2a945b0..c7bf603 100644
--- a/drivers/media/IR/keymaps/rc-avermedia-cardbus.c
+++ b/drivers/media/IR/keymaps/rc-avermedia-cardbus.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Oldrich Jedlicka <oldium.pro@seznam.cz> */
 
diff --git a/drivers/media/IR/keymaps/rc-avermedia-dvbt.c b/drivers/media/IR/keymaps/rc-avermedia-dvbt.c
index 39dde62..32339c8 100644
--- a/drivers/media/IR/keymaps/rc-avermedia-dvbt.c
+++ b/drivers/media/IR/keymaps/rc-avermedia-dvbt.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Matt Jesson <dvb@jesson.eclipse.co.uk */
 
diff --git a/drivers/media/IR/keymaps/rc-avermedia-m135a-rm-jx.c b/drivers/media/IR/keymaps/rc-avermedia-m135a-rm-jx.c
index 101e7ea..fe7a76f 100644
--- a/drivers/media/IR/keymaps/rc-avermedia-m135a-rm-jx.c
+++ b/drivers/media/IR/keymaps/rc-avermedia-m135a-rm-jx.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
  * Avermedia M135A with IR model RM-JX
diff --git a/drivers/media/IR/keymaps/rc-avermedia.c b/drivers/media/IR/keymaps/rc-avermedia.c
index 21effd5..ebb6ff4 100644
--- a/drivers/media/IR/keymaps/rc-avermedia.c
+++ b/drivers/media/IR/keymaps/rc-avermedia.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Alex Hermann <gaaf@gmx.net> */
 
diff --git a/drivers/media/IR/keymaps/rc-avertv-303.c b/drivers/media/IR/keymaps/rc-avertv-303.c
index 971c59d..a2d7372 100644
--- a/drivers/media/IR/keymaps/rc-avertv-303.c
+++ b/drivers/media/IR/keymaps/rc-avertv-303.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* AVERTV STUDIO 303 Remote */
 
diff --git a/drivers/media/IR/keymaps/rc-behold-columbus.c b/drivers/media/IR/keymaps/rc-behold-columbus.c
index 9f56c98..1702137 100644
--- a/drivers/media/IR/keymaps/rc-behold-columbus.c
+++ b/drivers/media/IR/keymaps/rc-behold-columbus.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Beholder Intl. Ltd. 2008
  * Dmitry Belimov d.belimov@google.com
diff --git a/drivers/media/IR/keymaps/rc-behold.c b/drivers/media/IR/keymaps/rc-behold.c
index abc140b..5f30f5d 100644
--- a/drivers/media/IR/keymaps/rc-behold.c
+++ b/drivers/media/IR/keymaps/rc-behold.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
  * Igor Kuznetsov <igk72@ya.ru>
diff --git a/drivers/media/IR/keymaps/rc-budget-ci-old.c b/drivers/media/IR/keymaps/rc-budget-ci-old.c
index 64c2ac9..fdc9f1a 100644
--- a/drivers/media/IR/keymaps/rc-budget-ci-old.c
+++ b/drivers/media/IR/keymaps/rc-budget-ci-old.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* From reading the following remotes:
  * Zenith Universal 7 / TV Mode 807 / VCR Mode 837
diff --git a/drivers/media/IR/keymaps/rc-cinergy-1400.c b/drivers/media/IR/keymaps/rc-cinergy-1400.c
index 074f2c2..f45761a 100644
--- a/drivers/media/IR/keymaps/rc-cinergy-1400.c
+++ b/drivers/media/IR/keymaps/rc-cinergy-1400.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Cinergy 1400 DVB-T */
 
diff --git a/drivers/media/IR/keymaps/rc-cinergy.c b/drivers/media/IR/keymaps/rc-cinergy.c
index cf84c3d..656cada 100644
--- a/drivers/media/IR/keymaps/rc-cinergy.c
+++ b/drivers/media/IR/keymaps/rc-cinergy.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode cinergy[] = {
 	{ 0x00, KEY_0 },
diff --git a/drivers/media/IR/keymaps/rc-dm1105-nec.c b/drivers/media/IR/keymaps/rc-dm1105-nec.c
index 90684d0..8ffedf0 100644
--- a/drivers/media/IR/keymaps/rc-dm1105-nec.c
+++ b/drivers/media/IR/keymaps/rc-dm1105-nec.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* DVBWorld remotes
    Igor M. Liplianin <liplianin@me.by>
diff --git a/drivers/media/IR/keymaps/rc-dntv-live-dvb-t.c b/drivers/media/IR/keymaps/rc-dntv-live-dvb-t.c
index 8a4027a..7bf9674 100644
--- a/drivers/media/IR/keymaps/rc-dntv-live-dvb-t.c
+++ b/drivers/media/IR/keymaps/rc-dntv-live-dvb-t.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* DigitalNow DNTV Live DVB-T Remote */
 
diff --git a/drivers/media/IR/keymaps/rc-dntv-live-dvbt-pro.c b/drivers/media/IR/keymaps/rc-dntv-live-dvbt-pro.c
index 6f4d607..8815a60 100644
--- a/drivers/media/IR/keymaps/rc-dntv-live-dvbt-pro.c
+++ b/drivers/media/IR/keymaps/rc-dntv-live-dvbt-pro.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* DigitalNow DNTV Live! DVB-T Pro Remote */
 
diff --git a/drivers/media/IR/keymaps/rc-em-terratec.c b/drivers/media/IR/keymaps/rc-em-terratec.c
index 3130c9c..6c16941 100644
--- a/drivers/media/IR/keymaps/rc-em-terratec.c
+++ b/drivers/media/IR/keymaps/rc-em-terratec.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode em_terratec[] = {
 	{ 0x01, KEY_CHANNEL },
diff --git a/drivers/media/IR/keymaps/rc-empty.c b/drivers/media/IR/keymaps/rc-empty.c
index 3b338d8..6091b96 100644
--- a/drivers/media/IR/keymaps/rc-empty.c
+++ b/drivers/media/IR/keymaps/rc-empty.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* empty keytable, can be used as placeholder for not-yet created keytables */
 
diff --git a/drivers/media/IR/keymaps/rc-encore-enltv-fm53.c b/drivers/media/IR/keymaps/rc-encore-enltv-fm53.c
index 4b81696..c55dd20 100644
--- a/drivers/media/IR/keymaps/rc-encore-enltv-fm53.c
+++ b/drivers/media/IR/keymaps/rc-encore-enltv-fm53.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Encore ENLTV-FM v5.3
    Mauro Carvalho Chehab <mchehab@infradead.org>
diff --git a/drivers/media/IR/keymaps/rc-encore-enltv.c b/drivers/media/IR/keymaps/rc-encore-enltv.c
index 9fabffd..06049c3 100644
--- a/drivers/media/IR/keymaps/rc-encore-enltv.c
+++ b/drivers/media/IR/keymaps/rc-encore-enltv.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Encore ENLTV-FM  - black plastic, white front cover with white glowing buttons
     Juan Pablo Sormani <sorman@gmail.com> */
diff --git a/drivers/media/IR/keymaps/rc-encore-enltv2.c b/drivers/media/IR/keymaps/rc-encore-enltv2.c
index efefd51..3795eb8 100644
--- a/drivers/media/IR/keymaps/rc-encore-enltv2.c
+++ b/drivers/media/IR/keymaps/rc-encore-enltv2.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Encore ENLTV2-FM  - silver plastic - "Wand Media" written at the botton
     Mauro Carvalho Chehab <mchehab@infradead.org> */
diff --git a/drivers/media/IR/keymaps/rc-evga-indtube.c b/drivers/media/IR/keymaps/rc-evga-indtube.c
index 3f3fb13..adf78e1 100644
--- a/drivers/media/IR/keymaps/rc-evga-indtube.c
+++ b/drivers/media/IR/keymaps/rc-evga-indtube.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* EVGA inDtube
    Devin Heitmueller <devin.heitmueller@gmail.com>
diff --git a/drivers/media/IR/keymaps/rc-eztv.c b/drivers/media/IR/keymaps/rc-eztv.c
index 660907a..c00078c 100644
--- a/drivers/media/IR/keymaps/rc-eztv.c
+++ b/drivers/media/IR/keymaps/rc-eztv.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Alfons Geser <a.geser@cox.net>
  * updates from Job D. R. Borges <jobdrb@ig.com.br> */
diff --git a/drivers/media/IR/keymaps/rc-flydvb.c b/drivers/media/IR/keymaps/rc-flydvb.c
index a173c81..c694b54 100644
--- a/drivers/media/IR/keymaps/rc-flydvb.c
+++ b/drivers/media/IR/keymaps/rc-flydvb.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode flydvb[] = {
 	{ 0x01, KEY_ZOOM },		/* Full Screen */
diff --git a/drivers/media/IR/keymaps/rc-flyvideo.c b/drivers/media/IR/keymaps/rc-flyvideo.c
index 9c73043..c59fbe4 100644
--- a/drivers/media/IR/keymaps/rc-flyvideo.c
+++ b/drivers/media/IR/keymaps/rc-flyvideo.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode flyvideo[] = {
 	{ 0x0f, KEY_0 },
diff --git a/drivers/media/IR/keymaps/rc-fusionhdtv-mce.c b/drivers/media/IR/keymaps/rc-fusionhdtv-mce.c
index cdb1038..e2e09a1 100644
--- a/drivers/media/IR/keymaps/rc-fusionhdtv-mce.c
+++ b/drivers/media/IR/keymaps/rc-fusionhdtv-mce.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* DViCO FUSION HDTV MCE remote */
 
diff --git a/drivers/media/IR/keymaps/rc-gadmei-rm008z.c b/drivers/media/IR/keymaps/rc-gadmei-rm008z.c
index c16c0d1..f77ab33 100644
--- a/drivers/media/IR/keymaps/rc-gadmei-rm008z.c
+++ b/drivers/media/IR/keymaps/rc-gadmei-rm008z.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* GADMEI UTV330+ RM008Z remote
    Shine Liu <shinel@foxmail.com>
diff --git a/drivers/media/IR/keymaps/rc-genius-tvgo-a11mce.c b/drivers/media/IR/keymaps/rc-genius-tvgo-a11mce.c
index 89f8e38..b36ede9 100644
--- a/drivers/media/IR/keymaps/rc-genius-tvgo-a11mce.c
+++ b/drivers/media/IR/keymaps/rc-genius-tvgo-a11mce.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
  * Remote control for the Genius TVGO A11MCE
diff --git a/drivers/media/IR/keymaps/rc-gotview7135.c b/drivers/media/IR/keymaps/rc-gotview7135.c
index 52f025b..3b6048b 100644
--- a/drivers/media/IR/keymaps/rc-gotview7135.c
+++ b/drivers/media/IR/keymaps/rc-gotview7135.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Mike Baikov <mike@baikov.com> */
 
diff --git a/drivers/media/IR/keymaps/rc-hauppauge-new.c b/drivers/media/IR/keymaps/rc-hauppauge-new.c
index c6f8cd7..7d6c146 100644
--- a/drivers/media/IR/keymaps/rc-hauppauge-new.c
+++ b/drivers/media/IR/keymaps/rc-hauppauge-new.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Hauppauge: the newer, gray remotes (seems there are multiple
  * slightly different versions), shipped with cx88+ivtv cards.
diff --git a/drivers/media/IR/keymaps/rc-imon-mce.c b/drivers/media/IR/keymaps/rc-imon-mce.c
index e49f350..4e014f3 100644
--- a/drivers/media/IR/keymaps/rc-imon-mce.c
+++ b/drivers/media/IR/keymaps/rc-imon-mce.c
@@ -9,7 +9,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* mce-mode imon mce remote key table */
 static struct ir_scancode imon_mce[] = {
diff --git a/drivers/media/IR/keymaps/rc-imon-pad.c b/drivers/media/IR/keymaps/rc-imon-pad.c
index bc4db72..68194ff 100644
--- a/drivers/media/IR/keymaps/rc-imon-pad.c
+++ b/drivers/media/IR/keymaps/rc-imon-pad.c
@@ -9,7 +9,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
  * standard imon remote key table, which isn't really entirely
diff --git a/drivers/media/IR/keymaps/rc-iodata-bctv7e.c b/drivers/media/IR/keymaps/rc-iodata-bctv7e.c
index ef66002..76ff936 100644
--- a/drivers/media/IR/keymaps/rc-iodata-bctv7e.c
+++ b/drivers/media/IR/keymaps/rc-iodata-bctv7e.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* IO-DATA BCTV7E Remote */
 
diff --git a/drivers/media/IR/keymaps/rc-kaiomy.c b/drivers/media/IR/keymaps/rc-kaiomy.c
index 4c7883b..20bf013 100644
--- a/drivers/media/IR/keymaps/rc-kaiomy.c
+++ b/drivers/media/IR/keymaps/rc-kaiomy.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Kaiomy TVnPC U2
    Mauro Carvalho Chehab <mchehab@infradead.org>
diff --git a/drivers/media/IR/keymaps/rc-kworld-315u.c b/drivers/media/IR/keymaps/rc-kworld-315u.c
index 618c817..e140ea0 100644
--- a/drivers/media/IR/keymaps/rc-kworld-315u.c
+++ b/drivers/media/IR/keymaps/rc-kworld-315u.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Kworld 315U
  */
diff --git a/drivers/media/IR/keymaps/rc-kworld-plus-tv-analog.c b/drivers/media/IR/keymaps/rc-kworld-plus-tv-analog.c
index 366732f..21ebbfd 100644
--- a/drivers/media/IR/keymaps/rc-kworld-plus-tv-analog.c
+++ b/drivers/media/IR/keymaps/rc-kworld-plus-tv-analog.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Kworld Plus TV Analog Lite PCI IR
    Mauro Carvalho Chehab <mchehab@infradead.org>
diff --git a/drivers/media/IR/keymaps/rc-manli.c b/drivers/media/IR/keymaps/rc-manli.c
index 1e9fbfa..d062775 100644
--- a/drivers/media/IR/keymaps/rc-manli.c
+++ b/drivers/media/IR/keymaps/rc-manli.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Michael Tokarev <mjt@tls.msk.ru>
    http://www.corpit.ru/mjt/beholdTV/remote_control.jpg
diff --git a/drivers/media/IR/keymaps/rc-msi-tvanywhere-plus.c b/drivers/media/IR/keymaps/rc-msi-tvanywhere-plus.c
index eb8e42c..7173c5d 100644
--- a/drivers/media/IR/keymaps/rc-msi-tvanywhere-plus.c
+++ b/drivers/media/IR/keymaps/rc-msi-tvanywhere-plus.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
   Keycodes for remote on the MSI TV@nywhere Plus. The controller IC on the card
diff --git a/drivers/media/IR/keymaps/rc-msi-tvanywhere.c b/drivers/media/IR/keymaps/rc-msi-tvanywhere.c
index ef41185..6897c07 100644
--- a/drivers/media/IR/keymaps/rc-msi-tvanywhere.c
+++ b/drivers/media/IR/keymaps/rc-msi-tvanywhere.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* MSI TV@nywhere MASTER remote */
 
diff --git a/drivers/media/IR/keymaps/rc-nebula.c b/drivers/media/IR/keymaps/rc-nebula.c
index ccc50eb..ec98473 100644
--- a/drivers/media/IR/keymaps/rc-nebula.c
+++ b/drivers/media/IR/keymaps/rc-nebula.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode nebula[] = {
 	{ 0x00, KEY_0 },
diff --git a/drivers/media/IR/keymaps/rc-nec-terratec-cinergy-xs.c b/drivers/media/IR/keymaps/rc-nec-terratec-cinergy-xs.c
index e1b54d2..2ebd496 100644
--- a/drivers/media/IR/keymaps/rc-nec-terratec-cinergy-xs.c
+++ b/drivers/media/IR/keymaps/rc-nec-terratec-cinergy-xs.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Terratec Cinergy Hybrid T USB XS FM
    Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/IR/keymaps/rc-norwood.c b/drivers/media/IR/keymaps/rc-norwood.c
index e5849a6..f3d379a 100644
--- a/drivers/media/IR/keymaps/rc-norwood.c
+++ b/drivers/media/IR/keymaps/rc-norwood.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Norwood Micro (non-Pro) TV Tuner
    By Peter Naulls <peter@chocky.org>
diff --git a/drivers/media/IR/keymaps/rc-npgtech.c b/drivers/media/IR/keymaps/rc-npgtech.c
index b9ece1e..ecf616c 100644
--- a/drivers/media/IR/keymaps/rc-npgtech.c
+++ b/drivers/media/IR/keymaps/rc-npgtech.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode npgtech[] = {
 	{ 0x1d, KEY_SWITCHVIDEOMODE },	/* switch inputs */
diff --git a/drivers/media/IR/keymaps/rc-pctv-sedna.c b/drivers/media/IR/keymaps/rc-pctv-sedna.c
index 4129bb4..13b7f9d 100644
--- a/drivers/media/IR/keymaps/rc-pctv-sedna.c
+++ b/drivers/media/IR/keymaps/rc-pctv-sedna.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Mapping for the 28 key remote control as seen at
    http://www.sednacomputer.com/photo/cardbus-tv.jpg
diff --git a/drivers/media/IR/keymaps/rc-pinnacle-color.c b/drivers/media/IR/keymaps/rc-pinnacle-color.c
index 326e023..1f06180 100644
--- a/drivers/media/IR/keymaps/rc-pinnacle-color.c
+++ b/drivers/media/IR/keymaps/rc-pinnacle-color.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode pinnacle_color[] = {
 	{ 0x59, KEY_MUTE },
diff --git a/drivers/media/IR/keymaps/rc-pinnacle-grey.c b/drivers/media/IR/keymaps/rc-pinnacle-grey.c
index 14cb772..d0f6d6c 100644
--- a/drivers/media/IR/keymaps/rc-pinnacle-grey.c
+++ b/drivers/media/IR/keymaps/rc-pinnacle-grey.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode pinnacle_grey[] = {
 	{ 0x3a, KEY_0 },
diff --git a/drivers/media/IR/keymaps/rc-pinnacle-pctv-hd.c b/drivers/media/IR/keymaps/rc-pinnacle-pctv-hd.c
index 835bf4e..55b1ca1 100644
--- a/drivers/media/IR/keymaps/rc-pinnacle-pctv-hd.c
+++ b/drivers/media/IR/keymaps/rc-pinnacle-pctv-hd.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Pinnacle PCTV HD 800i mini remote */
 
diff --git a/drivers/media/IR/keymaps/rc-pixelview-mk12.c b/drivers/media/IR/keymaps/rc-pixelview-mk12.c
index 5a735d5..1417384 100644
--- a/drivers/media/IR/keymaps/rc-pixelview-mk12.c
+++ b/drivers/media/IR/keymaps/rc-pixelview-mk12.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
  * Keytable for MK-F12 IR remote provided together with Pixelview
diff --git a/drivers/media/IR/keymaps/rc-pixelview-new.c b/drivers/media/IR/keymaps/rc-pixelview-new.c
index 7bbbbf5..10b9ef7 100644
--- a/drivers/media/IR/keymaps/rc-pixelview-new.c
+++ b/drivers/media/IR/keymaps/rc-pixelview-new.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
    Mauro Carvalho Chehab <mchehab@infradead.org>
diff --git a/drivers/media/IR/keymaps/rc-pixelview.c b/drivers/media/IR/keymaps/rc-pixelview.c
index 82ff12e..7d50692 100644
--- a/drivers/media/IR/keymaps/rc-pixelview.c
+++ b/drivers/media/IR/keymaps/rc-pixelview.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode pixelview[] = {
 
diff --git a/drivers/media/IR/keymaps/rc-powercolor-real-angel.c b/drivers/media/IR/keymaps/rc-powercolor-real-angel.c
index 7cef819..e2379db 100644
--- a/drivers/media/IR/keymaps/rc-powercolor-real-angel.c
+++ b/drivers/media/IR/keymaps/rc-powercolor-real-angel.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
  * Remote control for Powercolor Real Angel 330
diff --git a/drivers/media/IR/keymaps/rc-proteus-2309.c b/drivers/media/IR/keymaps/rc-proteus-2309.c
index 22e92d3..ef941e4 100644
--- a/drivers/media/IR/keymaps/rc-proteus-2309.c
+++ b/drivers/media/IR/keymaps/rc-proteus-2309.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Michal Majchrowicz <mmajchrowicz@gmail.com> */
 
diff --git a/drivers/media/IR/keymaps/rc-purpletv.c b/drivers/media/IR/keymaps/rc-purpletv.c
index 4e20fc2..fdae1cb 100644
--- a/drivers/media/IR/keymaps/rc-purpletv.c
+++ b/drivers/media/IR/keymaps/rc-purpletv.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode purpletv[] = {
 	{ 0x03, KEY_POWER },
diff --git a/drivers/media/IR/keymaps/rc-pv951.c b/drivers/media/IR/keymaps/rc-pv951.c
index 36679e7..45842c5 100644
--- a/drivers/media/IR/keymaps/rc-pv951.c
+++ b/drivers/media/IR/keymaps/rc-pv951.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Mark Phalan <phalanm@o2.ie> */
 
diff --git a/drivers/media/IR/keymaps/rc-rc5-hauppauge-new.c b/drivers/media/IR/keymaps/rc-rc5-hauppauge-new.c
index cc6b8f5..2055e2e 100644
--- a/drivers/media/IR/keymaps/rc-rc5-hauppauge-new.c
+++ b/drivers/media/IR/keymaps/rc-rc5-hauppauge-new.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /*
  * Hauppauge:the newer, gray remotes (seems there are multiple
diff --git a/drivers/media/IR/keymaps/rc-rc5-tv.c b/drivers/media/IR/keymaps/rc-rc5-tv.c
index 73cce2f..7ffbd25 100644
--- a/drivers/media/IR/keymaps/rc-rc5-tv.c
+++ b/drivers/media/IR/keymaps/rc-rc5-tv.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* generic RC5 keytable                                          */
 /* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */
diff --git a/drivers/media/IR/keymaps/rc-real-audio-220-32-keys.c b/drivers/media/IR/keymaps/rc-real-audio-220-32-keys.c
index ab1a6d2..51508c3 100644
--- a/drivers/media/IR/keymaps/rc-real-audio-220-32-keys.c
+++ b/drivers/media/IR/keymaps/rc-real-audio-220-32-keys.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Zogis Real Audio 220 - 32 keys IR */
 
diff --git a/drivers/media/IR/keymaps/rc-tbs-nec.c b/drivers/media/IR/keymaps/rc-tbs-nec.c
index 3309631..1c01270 100644
--- a/drivers/media/IR/keymaps/rc-tbs-nec.c
+++ b/drivers/media/IR/keymaps/rc-tbs-nec.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode tbs_nec[] = {
 	{ 0x04, KEY_POWER2},	/*power*/
diff --git a/drivers/media/IR/keymaps/rc-terratec-cinergy-xs.c b/drivers/media/IR/keymaps/rc-terratec-cinergy-xs.c
index 5326a0b..1699c3f 100644
--- a/drivers/media/IR/keymaps/rc-terratec-cinergy-xs.c
+++ b/drivers/media/IR/keymaps/rc-terratec-cinergy-xs.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Terratec Cinergy Hybrid T USB XS
    Devin Heitmueller <dheitmueller@linuxtv.org>
diff --git a/drivers/media/IR/keymaps/rc-tevii-nec.c b/drivers/media/IR/keymaps/rc-tevii-nec.c
index e30d411..6edc662 100644
--- a/drivers/media/IR/keymaps/rc-tevii-nec.c
+++ b/drivers/media/IR/keymaps/rc-tevii-nec.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode tevii_nec[] = {
 	{ 0x0a, KEY_POWER2},
diff --git a/drivers/media/IR/keymaps/rc-tt-1500.c b/drivers/media/IR/keymaps/rc-tt-1500.c
index bc88de0..79b5d19 100644
--- a/drivers/media/IR/keymaps/rc-tt-1500.c
+++ b/drivers/media/IR/keymaps/rc-tt-1500.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* for the Technotrend 1500 bundled remotes (grey and black): */
 
diff --git a/drivers/media/IR/keymaps/rc-videomate-s350.c b/drivers/media/IR/keymaps/rc-videomate-s350.c
index 4df7fcd..9fe9f4e 100644
--- a/drivers/media/IR/keymaps/rc-videomate-s350.c
+++ b/drivers/media/IR/keymaps/rc-videomate-s350.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode videomate_s350[] = {
 	{ 0x00, KEY_TV},
diff --git a/drivers/media/IR/keymaps/rc-videomate-tv-pvr.c b/drivers/media/IR/keymaps/rc-videomate-tv-pvr.c
index 776b0a6..e80ef1c 100644
--- a/drivers/media/IR/keymaps/rc-videomate-tv-pvr.c
+++ b/drivers/media/IR/keymaps/rc-videomate-tv-pvr.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 static struct ir_scancode videomate_tv_pvr[] = {
 	{ 0x14, KEY_MUTE },
diff --git a/drivers/media/IR/keymaps/rc-winfast-usbii-deluxe.c b/drivers/media/IR/keymaps/rc-winfast-usbii-deluxe.c
index 9d2d550..9bcb541 100644
--- a/drivers/media/IR/keymaps/rc-winfast-usbii-deluxe.c
+++ b/drivers/media/IR/keymaps/rc-winfast-usbii-deluxe.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Leadtek Winfast TV USB II Deluxe remote
    Magnus Alm <magnus.alm@gmail.com>
diff --git a/drivers/media/IR/keymaps/rc-winfast.c b/drivers/media/IR/keymaps/rc-winfast.c
index 0e90a3b..7a4a30b 100644
--- a/drivers/media/IR/keymaps/rc-winfast.c
+++ b/drivers/media/IR/keymaps/rc-winfast.c
@@ -10,7 +10,7 @@
  * (at your option) any later version.
  */
 
-#include <media/rc-map.h>
+#include <media/ir-core.h>
 
 /* Table for Leadtek Winfast Remote Controls - used by both bttv and cx88 */
 
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
index ad1303f..fc13aad 100644
--- a/include/media/ir-core.h
+++ b/include/media/ir-core.h
@@ -20,7 +20,7 @@
 #include <linux/kfifo.h>
 #include <linux/time.h>
 #include <linux/timer.h>
-#include <media/rc-map.h>
+#include <linux/input.h>
 
 extern int ir_core_debug;
 #define IR_dprintk(level, fmt, arg...)	if (ir_core_debug >= level) \
@@ -31,6 +31,14 @@ enum rc_driver_type {
 	RC_DRIVER_IR_RAW,	/* Needs a Infra-Red pulse/space decoder */
 };
 
+#define IR_TYPE_UNKNOWN	0
+#define IR_TYPE_RC5	(1  << 0)	/* Philips RC5 protocol */
+#define IR_TYPE_NEC	(1  << 1)
+#define IR_TYPE_RC6	(1  << 2)	/* Philips RC6 protocol */
+#define IR_TYPE_JVC	(1  << 3)	/* JVC protocol */
+#define IR_TYPE_SONY	(1  << 4)	/* Sony12/15/20 protocol */
+#define IR_TYPE_OTHER	(1u << 31)
+
 /**
  * struct ir_dev_props - Allow caller drivers to set special properties
  * @driver_type: specifies if the driver or hardware have already a decoder,
@@ -58,6 +66,27 @@ struct ir_dev_props {
 	void			(*close)(void *priv);
 };
 
+struct ir_scancode {
+	u32	scancode;
+	u32	keycode;
+};
+
+struct ir_scancode_table {
+	struct ir_scancode	*scan;
+	unsigned int		size;	/* Max number of entries */
+	unsigned int		len;	/* Used number of entries */
+	unsigned int		alloc;	/* Size of *scan in bytes */
+	u64			ir_type;
+	char			*name;
+	spinlock_t		lock;
+};
+
+struct rc_keymap {
+	struct list_head	 list;
+	struct ir_scancode_table map;
+};
+
+
 struct ir_input_dev {
 	struct device			dev;		/* device */
 	char				*driver_name;	/* Name of the driver module */
@@ -86,6 +115,12 @@ enum raw_event_type {
 
 #define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr)
 
+/* From rc-map.c */
+int ir_register_map(struct rc_keymap *map);
+void ir_unregister_map(struct rc_keymap *map);
+struct ir_scancode_table *get_rc_map(const char *name);
+void rc_map_init(void);
+
 /* From ir-keytable.c */
 int __ir_input_register(struct input_dev *dev,
 		      const struct ir_scancode_table *ir_codes,
@@ -145,4 +180,79 @@ static inline void ir_raw_event_reset(struct input_dev *input_dev)
 	ir_raw_event_handle(input_dev);
 }
 
+/* Names of the several keytables defined in-kernel */
+
+#define RC_MAP_ADSTECH_DVB_T_PCI         "rc-adstech-dvb-t-pci"
+#define RC_MAP_APAC_VIEWCOMP             "rc-apac-viewcomp"
+#define RC_MAP_ASUS_PC39                 "rc-asus-pc39"
+#define RC_MAP_ATI_TV_WONDER_HD_600      "rc-ati-tv-wonder-hd-600"
+#define RC_MAP_AVERMEDIA_A16D            "rc-avermedia-a16d"
+#define RC_MAP_AVERMEDIA_CARDBUS         "rc-avermedia-cardbus"
+#define RC_MAP_AVERMEDIA_DVBT            "rc-avermedia-dvbt"
+#define RC_MAP_AVERMEDIA_M135A_RM_JX     "rc-avermedia-m135a-rm-jx"
+#define RC_MAP_AVERMEDIA                 "rc-avermedia"
+#define RC_MAP_AVERTV_303                "rc-avertv-303"
+#define RC_MAP_BEHOLD_COLUMBUS           "rc-behold-columbus"
+#define RC_MAP_BEHOLD                    "rc-behold"
+#define RC_MAP_BUDGET_CI_OLD             "rc-budget-ci-old"
+#define RC_MAP_CINERGY_1400              "rc-cinergy-1400"
+#define RC_MAP_CINERGY                   "rc-cinergy"
+#define RC_MAP_DM1105_NEC                "rc-dm1105-nec"
+#define RC_MAP_DNTV_LIVE_DVBT_PRO        "rc-dntv-live-dvbt-pro"
+#define RC_MAP_DNTV_LIVE_DVB_T           "rc-dntv-live-dvb-t"
+#define RC_MAP_EMPTY                     "rc-empty"
+#define RC_MAP_EM_TERRATEC               "rc-em-terratec"
+#define RC_MAP_ENCORE_ENLTV2             "rc-encore-enltv2"
+#define RC_MAP_ENCORE_ENLTV_FM53         "rc-encore-enltv-fm53"
+#define RC_MAP_ENCORE_ENLTV              "rc-encore-enltv"
+#define RC_MAP_EVGA_INDTUBE              "rc-evga-indtube"
+#define RC_MAP_EZTV                      "rc-eztv"
+#define RC_MAP_FLYDVB                    "rc-flydvb"
+#define RC_MAP_FLYVIDEO                  "rc-flyvideo"
+#define RC_MAP_FUSIONHDTV_MCE            "rc-fusionhdtv-mce"
+#define RC_MAP_GADMEI_RM008Z             "rc-gadmei-rm008z"
+#define RC_MAP_GENIUS_TVGO_A11MCE        "rc-genius-tvgo-a11mce"
+#define RC_MAP_GOTVIEW7135               "rc-gotview7135"
+#define RC_MAP_HAUPPAUGE_NEW             "rc-hauppauge-new"
+#define RC_MAP_IMON_MCE                  "rc-imon-mce"
+#define RC_MAP_IMON_PAD                  "rc-imon-pad"
+#define RC_MAP_IODATA_BCTV7E             "rc-iodata-bctv7e"
+#define RC_MAP_KAIOMY                    "rc-kaiomy"
+#define RC_MAP_KWORLD_315U               "rc-kworld-315u"
+#define RC_MAP_KWORLD_PLUS_TV_ANALOG     "rc-kworld-plus-tv-analog"
+#define RC_MAP_MANLI                     "rc-manli"
+#define RC_MAP_MSI_TVANYWHERE_PLUS       "rc-msi-tvanywhere-plus"
+#define RC_MAP_MSI_TVANYWHERE            "rc-msi-tvanywhere"
+#define RC_MAP_NEBULA                    "rc-nebula"
+#define RC_MAP_NEC_TERRATEC_CINERGY_XS   "rc-nec-terratec-cinergy-xs"
+#define RC_MAP_NORWOOD                   "rc-norwood"
+#define RC_MAP_NPGTECH                   "rc-npgtech"
+#define RC_MAP_PCTV_SEDNA                "rc-pctv-sedna"
+#define RC_MAP_PINNACLE_COLOR            "rc-pinnacle-color"
+#define RC_MAP_PINNACLE_GREY             "rc-pinnacle-grey"
+#define RC_MAP_PINNACLE_PCTV_HD          "rc-pinnacle-pctv-hd"
+#define RC_MAP_PIXELVIEW_NEW             "rc-pixelview-new"
+#define RC_MAP_PIXELVIEW                 "rc-pixelview"
+#define RC_MAP_PIXELVIEW_MK12            "rc-pixelview-mk12"
+#define RC_MAP_POWERCOLOR_REAL_ANGEL     "rc-powercolor-real-angel"
+#define RC_MAP_PROTEUS_2309              "rc-proteus-2309"
+#define RC_MAP_PURPLETV                  "rc-purpletv"
+#define RC_MAP_PV951                     "rc-pv951"
+#define RC_MAP_RC5_HAUPPAUGE_NEW         "rc-rc5-hauppauge-new"
+#define RC_MAP_RC5_TV                    "rc-rc5-tv"
+#define RC_MAP_REAL_AUDIO_220_32_KEYS    "rc-real-audio-220-32-keys"
+#define RC_MAP_TBS_NEC                   "rc-tbs-nec"
+#define RC_MAP_TERRATEC_CINERGY_XS       "rc-terratec-cinergy-xs"
+#define RC_MAP_TEVII_NEC                 "rc-tevii-nec"
+#define RC_MAP_TT_1500                   "rc-tt-1500"
+#define RC_MAP_VIDEOMATE_S350            "rc-videomate-s350"
+#define RC_MAP_VIDEOMATE_TV_PVR          "rc-videomate-tv-pvr"
+#define RC_MAP_WINFAST                   "rc-winfast"
+#define RC_MAP_WINFAST_USBII_DELUXE      "rc-winfast-usbii-deluxe"
+/*
+ * Please, do not just append newer Remote Controller names at the end.
+ * The names should be ordered in alphabetical order
+ */
+
 #endif /* _IR_CORE */
+
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
deleted file mode 100644
index 5833966..0000000
--- a/include/media/rc-map.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * rc-map.h - define RC map names used by RC drivers
- *
- * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <linux/input.h>
-
-#define IR_TYPE_UNKNOWN	0
-#define IR_TYPE_RC5	(1  << 0)	/* Philips RC5 protocol */
-#define IR_TYPE_NEC	(1  << 1)
-#define IR_TYPE_RC6	(1  << 2)	/* Philips RC6 protocol */
-#define IR_TYPE_JVC	(1  << 3)	/* JVC protocol */
-#define IR_TYPE_SONY	(1  << 4)	/* Sony12/15/20 protocol */
-#define IR_TYPE_OTHER	(1u << 31)
-
-struct ir_scancode {
-	u32	scancode;
-	u32	keycode;
-};
-
-struct ir_scancode_table {
-	struct ir_scancode	*scan;
-	unsigned int		size;	/* Max number of entries */
-	unsigned int		len;	/* Used number of entries */
-	unsigned int		alloc;	/* Size of *scan in bytes */
-	u64			ir_type;
-	char			*name;
-	spinlock_t		lock;
-};
-
-struct rc_keymap {
-	struct list_head	 list;
-	struct ir_scancode_table map;
-};
-
-/* Routines from rc-map.c */
-
-int ir_register_map(struct rc_keymap *map);
-void ir_unregister_map(struct rc_keymap *map);
-struct ir_scancode_table *get_rc_map(const char *name);
-void rc_map_init(void);
-
-/* Names of the several keytables defined in-kernel */
-
-#define RC_MAP_ADSTECH_DVB_T_PCI         "rc-adstech-dvb-t-pci"
-#define RC_MAP_APAC_VIEWCOMP             "rc-apac-viewcomp"
-#define RC_MAP_ASUS_PC39                 "rc-asus-pc39"
-#define RC_MAP_ATI_TV_WONDER_HD_600      "rc-ati-tv-wonder-hd-600"
-#define RC_MAP_AVERMEDIA_A16D            "rc-avermedia-a16d"
-#define RC_MAP_AVERMEDIA_CARDBUS         "rc-avermedia-cardbus"
-#define RC_MAP_AVERMEDIA_DVBT            "rc-avermedia-dvbt"
-#define RC_MAP_AVERMEDIA_M135A_RM_JX     "rc-avermedia-m135a-rm-jx"
-#define RC_MAP_AVERMEDIA                 "rc-avermedia"
-#define RC_MAP_AVERTV_303                "rc-avertv-303"
-#define RC_MAP_BEHOLD_COLUMBUS           "rc-behold-columbus"
-#define RC_MAP_BEHOLD                    "rc-behold"
-#define RC_MAP_BUDGET_CI_OLD             "rc-budget-ci-old"
-#define RC_MAP_CINERGY_1400              "rc-cinergy-1400"
-#define RC_MAP_CINERGY                   "rc-cinergy"
-#define RC_MAP_DM1105_NEC                "rc-dm1105-nec"
-#define RC_MAP_DNTV_LIVE_DVBT_PRO        "rc-dntv-live-dvbt-pro"
-#define RC_MAP_DNTV_LIVE_DVB_T           "rc-dntv-live-dvb-t"
-#define RC_MAP_EMPTY                     "rc-empty"
-#define RC_MAP_EM_TERRATEC               "rc-em-terratec"
-#define RC_MAP_ENCORE_ENLTV2             "rc-encore-enltv2"
-#define RC_MAP_ENCORE_ENLTV_FM53         "rc-encore-enltv-fm53"
-#define RC_MAP_ENCORE_ENLTV              "rc-encore-enltv"
-#define RC_MAP_EVGA_INDTUBE              "rc-evga-indtube"
-#define RC_MAP_EZTV                      "rc-eztv"
-#define RC_MAP_FLYDVB                    "rc-flydvb"
-#define RC_MAP_FLYVIDEO                  "rc-flyvideo"
-#define RC_MAP_FUSIONHDTV_MCE            "rc-fusionhdtv-mce"
-#define RC_MAP_GADMEI_RM008Z             "rc-gadmei-rm008z"
-#define RC_MAP_GENIUS_TVGO_A11MCE        "rc-genius-tvgo-a11mce"
-#define RC_MAP_GOTVIEW7135               "rc-gotview7135"
-#define RC_MAP_HAUPPAUGE_NEW             "rc-hauppauge-new"
-#define RC_MAP_IMON_MCE                  "rc-imon-mce"
-#define RC_MAP_IMON_PAD                  "rc-imon-pad"
-#define RC_MAP_IODATA_BCTV7E             "rc-iodata-bctv7e"
-#define RC_MAP_KAIOMY                    "rc-kaiomy"
-#define RC_MAP_KWORLD_315U               "rc-kworld-315u"
-#define RC_MAP_KWORLD_PLUS_TV_ANALOG     "rc-kworld-plus-tv-analog"
-#define RC_MAP_MANLI                     "rc-manli"
-#define RC_MAP_MSI_TVANYWHERE_PLUS       "rc-msi-tvanywhere-plus"
-#define RC_MAP_MSI_TVANYWHERE            "rc-msi-tvanywhere"
-#define RC_MAP_NEBULA                    "rc-nebula"
-#define RC_MAP_NEC_TERRATEC_CINERGY_XS   "rc-nec-terratec-cinergy-xs"
-#define RC_MAP_NORWOOD                   "rc-norwood"
-#define RC_MAP_NPGTECH                   "rc-npgtech"
-#define RC_MAP_PCTV_SEDNA                "rc-pctv-sedna"
-#define RC_MAP_PINNACLE_COLOR            "rc-pinnacle-color"
-#define RC_MAP_PINNACLE_GREY             "rc-pinnacle-grey"
-#define RC_MAP_PINNACLE_PCTV_HD          "rc-pinnacle-pctv-hd"
-#define RC_MAP_PIXELVIEW_NEW             "rc-pixelview-new"
-#define RC_MAP_PIXELVIEW                 "rc-pixelview"
-#define RC_MAP_PIXELVIEW_MK12            "rc-pixelview-mk12"
-#define RC_MAP_POWERCOLOR_REAL_ANGEL     "rc-powercolor-real-angel"
-#define RC_MAP_PROTEUS_2309              "rc-proteus-2309"
-#define RC_MAP_PURPLETV                  "rc-purpletv"
-#define RC_MAP_PV951                     "rc-pv951"
-#define RC_MAP_RC5_HAUPPAUGE_NEW         "rc-rc5-hauppauge-new"
-#define RC_MAP_RC5_TV                    "rc-rc5-tv"
-#define RC_MAP_REAL_AUDIO_220_32_KEYS    "rc-real-audio-220-32-keys"
-#define RC_MAP_TBS_NEC                   "rc-tbs-nec"
-#define RC_MAP_TERRATEC_CINERGY_XS       "rc-terratec-cinergy-xs"
-#define RC_MAP_TEVII_NEC                 "rc-tevii-nec"
-#define RC_MAP_TT_1500                   "rc-tt-1500"
-#define RC_MAP_VIDEOMATE_S350            "rc-videomate-s350"
-#define RC_MAP_VIDEOMATE_TV_PVR          "rc-videomate-tv-pvr"
-#define RC_MAP_WINFAST                   "rc-winfast"
-#define RC_MAP_WINFAST_USBII_DELUXE      "rc-winfast-usbii-deluxe"
-/*
- * Please, do not just append newer Remote Controller names at the end.
- * The names should be ordered in alphabetical order
- */


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/8] ir-core: convert em28xx to not use ir-functions.c
  2010-06-07 19:32 ` [PATCH 2/8] ir-core: convert em28xx " David Härdeman
@ 2010-06-27 10:23   ` Mauro Carvalho Chehab
  2010-06-27 11:19     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 20+ messages in thread
From: Mauro Carvalho Chehab @ 2010-06-27 10:23 UTC (permalink / raw)
  To: David Härdeman; +Cc: linux-media

Em 07-06-2010 16:32, David Härdeman escreveu:
> Convert drivers/media/video/em28xx/em28xx-input.c to not use ir-functions.c
> 
> Signed-off-by: David Härdeman <david@hardeman.nu>

This patch caused a bad effect: if some key were pressed before loading the driver, it
causes endless repetitions of the last keycode:

[ 2126.019882] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07
[ 2126.126629] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07
[ 2126.233253] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07
[ 2126.339875] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07
[ 2126.446625] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07

I'll try to fix it and apply a patch to solve it.

Cheers,
Mauro

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/8] ir-core: convert em28xx to not use ir-functions.c
  2010-06-27 10:23   ` Mauro Carvalho Chehab
@ 2010-06-27 11:19     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 20+ messages in thread
From: Mauro Carvalho Chehab @ 2010-06-27 11:19 UTC (permalink / raw)
  To: David Härdeman; +Cc: linux-media

Em 27-06-2010 07:23, Mauro Carvalho Chehab escreveu:
> Em 07-06-2010 16:32, David Härdeman escreveu:
>> Convert drivers/media/video/em28xx/em28xx-input.c to not use ir-functions.c
>>
>> Signed-off-by: David Härdeman <david@hardeman.nu>
> 
> This patch caused a bad effect: if some key were pressed before loading the driver, it
> causes endless repetitions of the last keycode:
> 
> [ 2126.019882] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07
> [ 2126.126629] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07
> [ 2126.233253] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07
> [ 2126.339875] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07
> [ 2126.446625] em28xx IR (em28xx #0)/ir: ir->get_key result tb=01 rc=01 lr=01 data=1e07
> 
> I'll try to fix it and apply a patch to solve it.

Hmm.. in a matter of fact, the problem were in the printk... it were generating one line for
each poll interval.

After fixing it, your patch looks ok:

[ 3072.019846] em28xx IR (em28xx #0)/ir: em28xx_ir_handle_key: toggle: 0, count: 1, key 0x1e01
[ 3072.028390] ir_g_keycode_from_table: em28xx IR (em28xx #0): scancode 0x1e01 keycode 0x02
[ 3072.036655] ir_keydown: em28xx IR (em28xx #0): key down event, key 0x0002, scancode 0x1e01
[ 3072.143218] em28xx IR (em28xx #0)/ir: em28xx_ir_handle_key: toggle: 0, count: 2, key 0x1e01
[ 3072.151773] ir_g_keycode_from_table: em28xx IR (em28xx #0): scancode 0x1e01 keycode 0x02
[ 3072.409709] ir_keyup: keyup key 0x0002

Also, the test for read_count > 0 is not needed, and, in fact, can cause loosing one key when
the 6-bits wide repetition counter reaches their maximum value:

[ 3484.999804] em28xx IR (em28xx #0)/ir: em28xx_ir_handle_key: toggle: 0, count: 127, key 0x1e02
[ 3485.116431] em28xx IR (em28xx #0)/ir: em28xx_ir_handle_key: toggle: 0, count: 0, key 0x1e02

---

em28xx-input: Don't generate one debug message for every get_key read

Instead of generating one printk for every IR read, prints it only when 
count is different from the last count.

While here, as this code is called on every 100ms during the runtime 
lifetime, do some performance optimization, assuming that, under normal 
circumstances, it is unlikely that the driver would get a new key/key
repeat on every poll.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index dd6d528..6759cd5 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -292,18 +292,15 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
 
 	/* read the registers containing the IR status */
 	result = ir->get_key(ir, &poll_result);
-	if (result < 0) {
+	if (unlikely(result < 0)) {
 		dprintk("ir->get_key() failed %d\n", result);
 		return;
 	}
 
-	dprintk("ir->get_key result tb=%02x rc=%02x lr=%02x data=%02x%02x\n",
-		poll_result.toggle_bit, poll_result.read_count,
-		ir->last_readcount, poll_result.rc_address,
-		poll_result.rc_data[0]);
-
-	if (poll_result.read_count > 0 &&
-	    poll_result.read_count != ir->last_readcount) {
+	if (unlikely(poll_result.read_count != ir->last_readcount)) {
+		dprintk("%s: toggle: %d, count: %d, key 0x%02x%02x\n", __func__,
+			poll_result.toggle_bit, poll_result.read_count,
+			poll_result.rc_address, poll_result.rc_data[0]);
 		if (ir->full_code)
 			ir_keydown(ir->input,
 				   poll_result.rc_address << 8 |
@@ -313,17 +310,17 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
 			ir_keydown(ir->input,
 				   poll_result.rc_data[0],
 				   poll_result.toggle_bit);
-	}
 
-	if (ir->dev->chip_id == CHIP_ID_EM2874)
-		/* The em2874 clears the readcount field every time the
-		   register is read.  The em2860/2880 datasheet says that it
-		   is supposed to clear the readcount, but it doesn't.  So with
-		   the em2874, we are looking for a non-zero read count as
-		   opposed to a readcount that is incrementing */
-		ir->last_readcount = 0;
-	else
-		ir->last_readcount = poll_result.read_count;
+		if (ir->dev->chip_id == CHIP_ID_EM2874)
+			/* The em2874 clears the readcount field every time the
+			   register is read.  The em2860/2880 datasheet says that it
+			   is supposed to clear the readcount, but it doesn't.  So with
+			   the em2874, we are looking for a non-zero read count as
+			   opposed to a readcount that is incrementing */
+			ir->last_readcount = 0;
+		else
+			ir->last_readcount = poll_result.read_count;
+	}
 }
 
 static void em28xx_ir_work(struct work_struct *work)

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/8] ir-core: partially convert bt8xx to not use ir-functions.c
  2010-06-07 19:32 ` [PATCH 5/8] ir-core: partially convert bt8xx " David Härdeman
@ 2010-06-27 12:11   ` Mauro Carvalho Chehab
  2010-06-27 15:14     ` Andy Walls
  2010-06-27 20:17     ` Jarod Wilson
  0 siblings, 2 replies; 20+ messages in thread
From: Mauro Carvalho Chehab @ 2010-06-27 12:11 UTC (permalink / raw)
  To: David Härdeman; +Cc: linux-media

Em 07-06-2010 16:32, David Härdeman escreveu:
> Partially convert drivers/media/video/bt8xx/bttv-input.c to
> not use ir-functions.c.
> 
> Since the last user is gone with this patch, also remove a
> bunch of code from ir-functions.c.

This patch breakd mceusb driver:

drivers/media/IR/mceusb.c: In function ‘mceusb_init_input_dev’:
drivers/media/IR/mceusb.c:774: error: invalid application of ‘sizeof’ to incomplete type ‘struct ir_input_state’ 
drivers/media/IR/mceusb.c:785: error: implicit declaration of function ‘ir_input_init’
make[1]: ** [drivers/media/IR/mceusb.o] Erro 1
make[1]: ** Esperando que outros processos terminem.
make: ** [drivers/media/IR/] Erro 2

Also, the description is wrong, since it changes not only bttv, but also cx23885 and saa7134.

Cheers,
Mauro

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/8] ir-core: partially convert bt8xx to not use ir-functions.c
  2010-06-27 12:11   ` Mauro Carvalho Chehab
@ 2010-06-27 15:14     ` Andy Walls
  2010-06-28  1:26       ` Mauro Carvalho Chehab
  2010-06-27 20:17     ` Jarod Wilson
  1 sibling, 1 reply; 20+ messages in thread
From: Andy Walls @ 2010-06-27 15:14 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: David Härdeman, linux-media

On Sun, 2010-06-27 at 09:11 -0300, Mauro Carvalho Chehab wrote:
> Em 07-06-2010 16:32, David Härdeman escreveu:
> > Partially convert drivers/media/video/bt8xx/bttv-input.c to
> > not use ir-functions.c.
> > 
> > Since the last user is gone with this patch, also remove a
> > bunch of code from ir-functions.c.
> 
> This patch breakd mceusb driver:
> 
> drivers/media/IR/mceusb.c: In function ‘mceusb_init_input_dev’:
> drivers/media/IR/mceusb.c:774: error: invalid application of ‘sizeof’ to incomplete type ‘struct ir_input_state’ 
> drivers/media/IR/mceusb.c:785: error: implicit declaration of function ‘ir_input_init’
> make[1]: ** [drivers/media/IR/mceusb.o] Erro 1
> make[1]: ** Esperando que outros processos terminem.
> make: ** [drivers/media/IR/] Erro 2
> 
> Also, the description is wrong, since it changes not only bttv, but also cx23885 and saa7134.

Mauro,

I'll be removing the RC5 and NEC decoding from the cx23885 driver
hopefully by the end of the day.  That will make parts of David's patch
obsolete.

I'll be developing off of the v4l-dvb.git staging/rc branch.  Is that
the right branch to use?

Also the IR registration Ooops is not patched in staging/rc, so the
cx23885 driver Oops-es on load.  Is it OK if I pull in (fetch & merge)
the patch from some other branch, or would it be easier for you if I
just use an uncommitted patch in my working tree?

Regards,
Andy

Mauro



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



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/8] ir-core: partially convert bt8xx to not use ir-functions.c
  2010-06-27 12:11   ` Mauro Carvalho Chehab
  2010-06-27 15:14     ` Andy Walls
@ 2010-06-27 20:17     ` Jarod Wilson
  2010-06-27 21:37       ` Andy Walls
  2010-06-27 23:17       ` MCEUSB memory leak and how to tell if ir_register_input() failure registered input_dev? Andy Walls
  1 sibling, 2 replies; 20+ messages in thread
From: Jarod Wilson @ 2010-06-27 20:17 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: David Härdeman, linux-media

On Sun, Jun 27, 2010 at 8:11 AM, Mauro Carvalho Chehab
<mchehab@redhat.com> wrote:
> Em 07-06-2010 16:32, David Härdeman escreveu:
>> Partially convert drivers/media/video/bt8xx/bttv-input.c to
>> not use ir-functions.c.
>>
>> Since the last user is gone with this patch, also remove a
>> bunch of code from ir-functions.c.
>
> This patch breakd mceusb driver:
>
> drivers/media/IR/mceusb.c: In function ‘mceusb_init_input_dev’:
> drivers/media/IR/mceusb.c:774: error: invalid application of ‘sizeof’ to incomplete type ‘struct ir_input_state’
> drivers/media/IR/mceusb.c:785: error: implicit declaration of function ‘ir_input_init’
> make[1]: ** [drivers/media/IR/mceusb.o] Erro 1
> make[1]: ** Esperando que outros processos terminem.
> make: ** [drivers/media/IR/] Erro 2

The mceusb driver doesn't actually need ir_input_state at all, and one
of my pending patches removes it.

https://patchwork.kernel.org/patch/106549/


-- 
Jarod Wilson
jarod@wilsonet.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/8] ir-core: partially convert bt8xx to not use ir-functions.c
  2010-06-27 20:17     ` Jarod Wilson
@ 2010-06-27 21:37       ` Andy Walls
  2010-06-27 23:17       ` MCEUSB memory leak and how to tell if ir_register_input() failure registered input_dev? Andy Walls
  1 sibling, 0 replies; 20+ messages in thread
From: Andy Walls @ 2010-06-27 21:37 UTC (permalink / raw)
  To: Jarod Wilson; +Cc: Mauro Carvalho Chehab, David Härdeman, linux-media

On Sun, 2010-06-27 at 16:17 -0400, Jarod Wilson wrote:
> On Sun, Jun 27, 2010 at 8:11 AM, Mauro Carvalho Chehab
> <mchehab@redhat.com> wrote:
> > Em 07-06-2010 16:32, David Härdeman escreveu:
> >> Partially convert drivers/media/video/bt8xx/bttv-input.c to
> >> not use ir-functions.c.
> >>
> >> Since the last user is gone with this patch, also remove a
> >> bunch of code from ir-functions.c.
> >
> > This patch breakd mceusb driver:
> >
> > drivers/media/IR/mceusb.c: In function ‘mceusb_init_input_dev’:
> > drivers/media/IR/mceusb.c:774: error: invalid application of ‘sizeof’ to incomplete type ‘struct ir_input_state’
> > drivers/media/IR/mceusb.c:785: error: implicit declaration of function ‘ir_input_init’
> > make[1]: ** [drivers/media/IR/mceusb.o] Erro 1
> > make[1]: ** Esperando que outros processos terminem.
> > make: ** [drivers/media/IR/] Erro 2
> 
> The mceusb driver doesn't actually need ir_input_state at all, 

I just came to that conclusion 5 minutes ago for the cx23885 driver as
well.  Right now it does use it, but once I get this conversion
complete, it won't need it either AFAICT.

I guess Mauro's build never got to the cx23885 driver.

Regards,
Andy



^ permalink raw reply	[flat|nested] 20+ messages in thread

* MCEUSB memory leak and how to tell if ir_register_input() failure registered input_dev?
  2010-06-27 20:17     ` Jarod Wilson
  2010-06-27 21:37       ` Andy Walls
@ 2010-06-27 23:17       ` Andy Walls
  2010-06-28  3:34         ` Jarod Wilson
  1 sibling, 1 reply; 20+ messages in thread
From: Andy Walls @ 2010-06-27 23:17 UTC (permalink / raw)
  To: Jarod Wilson; +Cc: Mauro Carvalho Chehab, David Härdeman, linux-media


Jarrod,

Looking at the patches branch from your WIP git tree:

Is mceusb_init_input_dev() supposed to allocate a struct ir_input_dev?
It looks like ir_register_input() handles that, and it is trashing your
pointer (memory leak).

Mauro and Jarrod,

When ir_register_input() fails, it doesn't indicate whether or not it
was able to register the input_dev or not.  To me it looks like it can
return with failure with the input_dev either way depending on the case.
This makes proper cleanup of the input_dev in my cx23885_input_init()
function difficult in the failure case, since the input subsystem has
two different deallocators depending on if the device had been
registered or not.

Regards,
Andy



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/8] ir-core: partially convert bt8xx to not use ir-functions.c
  2010-06-27 15:14     ` Andy Walls
@ 2010-06-28  1:26       ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 20+ messages in thread
From: Mauro Carvalho Chehab @ 2010-06-28  1:26 UTC (permalink / raw)
  To: Andy Walls; +Cc: David Härdeman, linux-media

Em 27-06-2010 12:14, Andy Walls escreveu:
> On Sun, 2010-06-27 at 09:11 -0300, Mauro Carvalho Chehab wrote:
>> Em 07-06-2010 16:32, David Härdeman escreveu:
>>> Partially convert drivers/media/video/bt8xx/bttv-input.c to
>>> not use ir-functions.c.
>>>
>>> Since the last user is gone with this patch, also remove a
>>> bunch of code from ir-functions.c.
>>
>> This patch breakd mceusb driver:
>>
>> drivers/media/IR/mceusb.c: In function ‘mceusb_init_input_dev’:
>> drivers/media/IR/mceusb.c:774: error: invalid application of ‘sizeof’ to incomplete type ‘struct ir_input_state’ 
>> drivers/media/IR/mceusb.c:785: error: implicit declaration of function ‘ir_input_init’
>> make[1]: ** [drivers/media/IR/mceusb.o] Erro 1
>> make[1]: ** Esperando que outros processos terminem.
>> make: ** [drivers/media/IR/] Erro 2
>>
>> Also, the description is wrong, since it changes not only bttv, but also cx23885 and saa7134.
> 
> Mauro,
> 
> I'll be removing the RC5 and NEC decoding from the cx23885 driver
> hopefully by the end of the day.  That will make parts of David's patch
> obsolete.

Ok. David, it is generally a good idea to break those patches into smaller ones, since,
when conflicts like this happens, we can just discard a patch at the series, or move it
to happen after another patch.

> I'll be developing off of the v4l-dvb.git staging/rc branch.  Is that
> the right branch to use?

Yes. I'll likely apply a few more patches there.
 
> Also the IR registration Ooops is not patched in staging/rc, so the
> cx23885 driver Oops-es on load.  Is it OK if I pull in (fetch & merge)
> the patch from some other branch, or would it be easier for you if I
> just use an uncommitted patch in my working tree?

Probably, it is ok if you send it with the fix pulled in.

I'll handle the conflicts when sending upstream.

Cheers,
Mauro

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: MCEUSB memory leak and how to tell if ir_register_input() failure registered input_dev?
  2010-06-27 23:17       ` MCEUSB memory leak and how to tell if ir_register_input() failure registered input_dev? Andy Walls
@ 2010-06-28  3:34         ` Jarod Wilson
  2010-07-03 13:20           ` Andy Walls
  0 siblings, 1 reply; 20+ messages in thread
From: Jarod Wilson @ 2010-06-28  3:34 UTC (permalink / raw)
  To: Andy Walls; +Cc: Mauro Carvalho Chehab, David Härdeman, linux-media

On Sun, Jun 27, 2010 at 7:17 PM, Andy Walls <awalls@md.metrocast.net> wrote:
>
> Jarrod,
>
> Looking at the patches branch from your WIP git tree:
>
> Is mceusb_init_input_dev() supposed to allocate a struct ir_input_dev?
> It looks like ir_register_input() handles that, and it is trashing your
> pointer (memory leak).

Eep, crap, you're right. Fixed locally (I think), will test it out and
ship off the patch probably tomorrow (exhausting weekend of watching
futbol and some heavy-duty bbq'ing, need to turn in early... ;).

Just double-checked, I actually cribbed that incorrectness from
imon.c, so I'll need to fix it there too. D'oh.

> Mauro and Jarrod,
>
> When ir_register_input() fails, it doesn't indicate whether or not it
> was able to register the input_dev or not.  To me it looks like it can
> return with failure with the input_dev either way depending on the case.
> This makes proper cleanup of the input_dev in my cx23885_input_init()
> function difficult in the failure case, since the input subsystem has
> two different deallocators depending on if the device had been
> registered or not.

Hm. I've done a double-take a few times now, but if
input_register_device is successful, and something later in
__ir_input_register fails, input_unregister_device *does* get called
within __ir_input_register, so all you should have to do is call
input_free_device in your init function's error path, no?

-- 
Jarod Wilson
jarod@wilsonet.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 8/8] ir-core: merge rc-map.h into ir-core.h
  2010-06-07 19:32 ` [PATCH 8/8] ir-core: merge rc-map.h into ir-core.h David Härdeman
@ 2010-06-28 17:45   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 20+ messages in thread
From: Mauro Carvalho Chehab @ 2010-06-28 17:45 UTC (permalink / raw)
  To: David Härdeman; +Cc: linux-media

Em 07-06-2010 16:32, David Härdeman escreveu:
> Haven't discussed this patch on the linux-media list yet, but
> merging rc-map.h into ir-core.h at least makes it much easier
> for me to get a good overview of the entire rc-core subsystem
> (and to make sweeping changes). Not sure if everyone agrees?

I don't like the idea of merging those headers. It will just slow
down the build time when a change at the core is applied, as all
rc tables would need to be rebuilt for no good reason.

Cheers,
Mauro

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: MCEUSB memory leak and how to tell if ir_register_input() failure  registered input_dev?
  2010-06-28  3:34         ` Jarod Wilson
@ 2010-07-03 13:20           ` Andy Walls
  0 siblings, 0 replies; 20+ messages in thread
From: Andy Walls @ 2010-07-03 13:20 UTC (permalink / raw)
  To: Jarod Wilson; +Cc: Mauro Carvalho Chehab, David Härdeman, linux-media

On Sun, 2010-06-27 at 23:34 -0400, Jarod Wilson wrote:
> On Sun, Jun 27, 2010 at 7:17 PM, Andy Walls <awalls@md.metrocast.net> wrote:

> > Mauro and Jarrod,
> >
> > When ir_register_input() fails, it doesn't indicate whether or not it
> > was able to register the input_dev or not.  To me it looks like it can
> > return with failure with the input_dev either way depending on the case.
> > This makes proper cleanup of the input_dev in my cx23885_input_init()
> > function difficult in the failure case, since the input subsystem has
> > two different deallocators depending on if the device had been
> > registered or not.
> 
> Hm. I've done a double-take a few times now, but if
> input_register_device is successful, and something later in
> __ir_input_register fails, input_unregister_device *does* get called
> within __ir_input_register, so all you should have to do is call
> input_free_device in your init function's error path, no?


I couldn't quite tell (with the constant stream of intteruptions I get
at times).  That's why I asked. :)

I'll double check today once I'm done with getting the CX23888 IR Tx
working.

Regards,
Andy


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-07-03 13:20 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-07 19:32 [PATCH 0/8] rc-core cleanups David Härdeman
2010-06-07 19:32 ` [PATCH 1/8] ir-core: convert mantis to not use ir-functions.c David Härdeman
2010-06-07 19:32 ` [PATCH 2/8] ir-core: convert em28xx " David Härdeman
2010-06-27 10:23   ` Mauro Carvalho Chehab
2010-06-27 11:19     ` Mauro Carvalho Chehab
2010-06-07 19:32 ` [PATCH 3/8] ir-core: partially convert cx88 " David Härdeman
2010-06-07 19:32 ` [PATCH 4/8] ir-core: partially convert ir-kbd-i2c.c " David Härdeman
2010-06-07 19:32 ` [PATCH 5/8] ir-core: partially convert bt8xx " David Härdeman
2010-06-27 12:11   ` Mauro Carvalho Chehab
2010-06-27 15:14     ` Andy Walls
2010-06-28  1:26       ` Mauro Carvalho Chehab
2010-06-27 20:17     ` Jarod Wilson
2010-06-27 21:37       ` Andy Walls
2010-06-27 23:17       ` MCEUSB memory leak and how to tell if ir_register_input() failure registered input_dev? Andy Walls
2010-06-28  3:34         ` Jarod Wilson
2010-07-03 13:20           ` Andy Walls
2010-06-07 19:32 ` [PATCH 6/8] ir-core: centralize sysfs raw decoder enabling/disabling David Härdeman
2010-06-07 19:32 ` [PATCH 7/8] ir-core: move decoding state to ir_raw_event_ctrl David Härdeman
2010-06-07 19:32 ` [PATCH 8/8] ir-core: merge rc-map.h into ir-core.h David Härdeman
2010-06-28 17:45   ` Mauro Carvalho Chehab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.