+@@ -1172,7 +1365,7 @@ int rc_register_device(struct rc_dev *de
+ rc = dev->change_protocol(dev, &rc_type);
+ if (rc < 0)
+ goto out_raw;
+- dev->enabled_protocols = rc_type;
++ dev->enabled_protocols[RC_FILTER_NORMAL] = rc_type;
+ }
+
+ mutex_unlock(&dev->lock);
+--- a/drivers/media/rc/redrat3.c
++++ b/drivers/media/rc/redrat3.c
+@@ -922,7 +922,7 @@ static struct rc_dev *redrat3_init_rc_de
+ rc->dev.parent = dev;
+ rc->priv = rr3;
+ rc->driver_type = RC_DRIVER_IR_RAW;
+- rc->allowed_protos = RC_BIT_ALL;
++ rc_set_allowed_protocols(rc, RC_BIT_ALL);
+ rc->timeout = US_TO_NS(2750);
+ rc->tx_ir = redrat3_transmit_ir;
+ rc->s_tx_carrier = redrat3_set_tx_carrier;
+--- a/drivers/media/rc/st_rc.c
++++ b/drivers/media/rc/st_rc.c
+@@ -287,7 +287,7 @@ static int st_rc_probe(struct platform_d
+ st_rc_hardware_init(rc_dev);
+
+ rdev->driver_type = RC_DRIVER_IR_RAW;
+- rdev->allowed_protos = RC_BIT_ALL;
++ rc_set_allowed_protocols(rdev, RC_BIT_ALL);
+ /* rx sampling rate is 10Mhz */
+ rdev->rx_resolution = 100;
+ rdev->timeout = US_TO_NS(MAX_SYMB_TIME);
+--- a/drivers/media/rc/streamzap.c
++++ b/drivers/media/rc/streamzap.c
+@@ -322,7 +322,7 @@ static struct rc_dev *streamzap_init_rc_
+ rdev->dev.parent = dev;
+ rdev->priv = sz;
+ rdev->driver_type = RC_DRIVER_IR_RAW;
+- rdev->allowed_protos = RC_BIT_ALL;
++ rc_set_allowed_protocols(rdev, RC_BIT_ALL);
+ rdev->driver_name = DRIVER_NAME;
+ rdev->map_name = RC_MAP_STREAMZAP;
+
+--- a/drivers/media/rc/ttusbir.c
++++ b/drivers/media/rc/ttusbir.c
+@@ -318,7 +318,7 @@ static int ttusbir_probe(struct usb_inte
+ usb_to_input_id(tt->udev, &rc->input_id);
+ rc->dev.parent = &intf->dev;
+ rc->driver_type = RC_DRIVER_IR_RAW;
+- rc->allowed_protos = RC_BIT_ALL;
++ rc_set_allowed_protocols(rc, RC_BIT_ALL);
+ rc->priv = tt;
+ rc->driver_name = DRIVER_NAME;
+ rc->map_name = RC_MAP_TT_1500;
+--- a/drivers/media/rc/winbond-cir.c
++++ b/drivers/media/rc/winbond-cir.c
+@@ -1082,7 +1082,7 @@ wbcir_probe(struct pnp_dev *device, cons
+ data->dev->dev.parent = &device->dev;
+ data->dev->timeout = MS_TO_NS(100);
+ data->dev->rx_resolution = US_TO_NS(2);
+- data->dev->allowed_protos = RC_BIT_ALL;
++ rc_set_allowed_protocols(data->dev, RC_BIT_ALL);
+
+ err = rc_register_device(data->dev);
+ if (err)
+--- a/drivers/media/usb/dvb-usb/dvb-usb-remote.c
++++ b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
+@@ -272,7 +272,7 @@ static int rc_core_dvb_usb_remote_init(s
+ dev->driver_name = d->props.rc.core.module_name;
+ dev->map_name = d->props.rc.core.rc_codes;
+ dev->change_protocol = d->props.rc.core.change_protocol;
+- dev->allowed_protos = d->props.rc.core.allowed_protos;
++ rc_set_allowed_protocols(dev, d->props.rc.core.allowed_protos);
+ dev->driver_type = d->props.rc.core.driver_type;
+ usb_to_input_id(d->udev, &dev->input_id);
+ dev->input_name = "IR-receiver inside an USB DVB receiver";
+--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
++++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+@@ -164,7 +164,7 @@ static int dvb_usbv2_remote_init(struct
+ dev->driver_name = (char *) d->props->driver_name;
+ dev->map_name = d->rc.map_name;
+ dev->driver_type = d->rc.driver_type;
+- dev->allowed_protos = d->rc.allowed_protos;
++ rc_set_allowed_protocols(dev, d->rc.allowed_protos);
+ dev->change_protocol = d->rc.change_protocol;
+ dev->priv = d;
+
+--- a/drivers/media/usb/em28xx/em28xx-input.c
++++ b/drivers/media/usb/em28xx/em28xx-input.c
+@@ -725,7 +725,7 @@ static int em28xx_ir_init(struct em28xx
+ case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
+ rc->map_name = RC_MAP_HAUPPAUGE;
+ ir->get_key_i2c = em28xx_get_key_em_haup;
+- rc->allowed_protos = RC_BIT_RC5;
++ rc_set_allowed_protocols(rc, RC_BIT_RC5);
+ break;
+ case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE:
+ rc->map_name = RC_MAP_WINFAST_USBII_DELUXE;
+@@ -741,7 +741,7 @@ static int em28xx_ir_init(struct em28xx
+ switch (dev->chip_id) {
+ case CHIP_ID_EM2860:
+ case CHIP_ID_EM2883:
+- rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC;
++ rc_set_allowed_protocols(rc, RC_BIT_RC5 | RC_BIT_NEC);
+ ir->get_key = default_polling_getkey;
+ break;
+ case CHIP_ID_EM2884:
+@@ -749,8 +749,8 @@ static int em28xx_ir_init(struct em28xx
+ case CHIP_ID_EM28174:
+ case CHIP_ID_EM28178:
+ ir->get_key = em2874_polling_getkey;
+- rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC |
+- RC_BIT_RC6_0;
++ rc_set_allowed_protocols(rc, RC_BIT_RC5 | RC_BIT_NEC |
++ RC_BIT_RC6_0);
+ break;
+ default:
+ err = -ENODEV;
+--- a/drivers/media/usb/tm6000/tm6000-input.c
++++ b/drivers/media/usb/tm6000/tm6000-input.c
+@@ -422,7 +422,7 @@ int tm6000_ir_init(struct tm6000_core *d
+ ir->rc = rc;
+
+ /* input setup */
+- rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC;
++ rc_set_allowed_protocols(rc, RC_BIT_RC5 | RC_BIT_NEC);
+ /* Neded, in order to support NEC remotes with 24 or 32 bits */
+ rc->scanmask = 0xffff;
+ rc->priv = ir;
+--- a/include/media/rc-core.h
++++ b/include/media/rc-core.h
+@@ -35,6 +35,29 @@ enum rc_driver_type {
+ };
+
+ /**
++ * struct rc_scancode_filter - Filter scan codes.
++ * @data: Scancode data to match.
++ * @mask: Mask of bits of scancode to compare.
++ */
++struct rc_scancode_filter {
++ u32 data;
++ u32 mask;
++};
++
++/**
++ * enum rc_filter_type - Filter type constants.
++ * @RC_FILTER_NORMAL: Filter for normal operation.
++ * @RC_FILTER_WAKEUP: Filter for waking from suspend.
++ * @RC_FILTER_MAX: Number of filter types.
++ */
++enum rc_filter_type {
++ RC_FILTER_NORMAL = 0,
++ RC_FILTER_WAKEUP,
++
++ RC_FILTER_MAX
++};
++
++/**
+ * struct rc_dev - represents a remote control device
+ * @dev: driver model's view of this device
+ * @input_name: name of the input child device
+@@ -50,8 +73,10 @@ enum rc_driver_type {
+ * @input_dev: the input child device used to communicate events to userspace
+ * @driver_type: specifies if protocol decoding is done in hardware or software
+ * @idle: used to keep track of RX state
+- * @allowed_protos: bitmask with the supported RC_BIT_* protocols
+- * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols
++ * @allowed_protocols: bitmask with the supported RC_BIT_* protocols for each
++ * filter type
++ * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols for each
++ * filter type
+ * @scanmask: some hardware decoders are not capable of providing the full
+ * scancode to the application. As this is a hardware limit, we can't do
+ * anything with it. Yet, as the same keycode table can be used with other
+@@ -70,7 +95,10 @@ enum rc_driver_type {
+ * @max_timeout: maximum timeout supported by device
+ * @rx_resolution : resolution (in ns) of input sampler
+ * @tx_resolution: resolution (in ns) of output sampler
++ * @scancode_filters: scancode filters (indexed by enum rc_filter_type)
+ * @change_protocol: allow changing the protocol used on hardware decoders
++ * @change_wakeup_protocol: allow changing the protocol used for wakeup
++ * filtering
+ * @open: callback to allow drivers to enable polling/irq when IR input device
+ * is opened.
+ * @close: callback to allow drivers to disable polling/irq when IR input device
+@@ -84,6 +112,7 @@ enum rc_driver_type {
+ * device doesn't interrupt host until it sees IR pulses
+ * @s_learning_mode: enable wide band receiver used for learning
+ * @s_carrier_report: enable carrier reports
++ * @s_filter: set the scancode filter of a given type
+ */
+ struct rc_dev {
+ struct device dev;
+@@ -99,8 +128,8 @@ struct rc_dev {
+ struct input_dev *input_dev;
+ enum rc_driver_type driver_type;
+ bool idle;
+- u64 allowed_protos;
+- u64 enabled_protocols;
++ u64 allowed_protocols[RC_FILTER_MAX];
++ u64 enabled_protocols[RC_FILTER_MAX];
+ u32 users;
+ u32 scanmask;
+ void *priv;
+@@ -116,7 +145,9 @@ struct rc_dev {
+ u32 max_timeout;
+ u32 rx_resolution;
+ u32 tx_resolution;
++ struct rc_scancode_filter scancode_filters[RC_FILTER_MAX];
+ int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
++ int (*change_wakeup_protocol)(struct rc_dev *dev, u64 *rc_type);
+ int (*open)(struct rc_dev *dev);
+ void (*close)(struct rc_dev *dev);
+ int (*s_tx_mask)(struct rc_dev *dev, u32 mask);
+@@ -127,10 +158,49 @@ struct rc_dev {
+ void (*s_idle)(struct rc_dev *dev, bool enable);
+ int (*s_learning_mode)(struct rc_dev *dev, int enable);
+ int (*s_carrier_report) (struct rc_dev *dev, int enable);
++ int (*s_filter)(struct rc_dev *dev,
++ enum rc_filter_type type,
++ struct rc_scancode_filter *filter);
+ };
+
+ #define to_rc_dev(d) container_of(d, struct rc_dev, dev)
+
++static inline bool rc_protocols_allowed(struct rc_dev *rdev, u64 protos)
++{
++ return rdev->allowed_protocols[RC_FILTER_NORMAL] & protos;
++}
++
++/* should be called prior to registration or with mutex held */
++static inline void rc_set_allowed_protocols(struct rc_dev *rdev, u64 protos)
++{
++ rdev->allowed_protocols[RC_FILTER_NORMAL] = protos;
++}
++
++static inline bool rc_protocols_enabled(struct rc_dev *rdev, u64 protos)
++{
++ return rdev->enabled_protocols[RC_FILTER_NORMAL] & protos;
++}
++
++/* should be called prior to registration or with mutex held */
++static inline void rc_set_enabled_protocols(struct rc_dev *rdev, u64 protos)
++{
++ rdev->enabled_protocols[RC_FILTER_NORMAL] = protos;
++}
++
++/* should be called prior to registration or with mutex held */
++static inline void rc_set_allowed_wakeup_protocols(struct rc_dev *rdev,
++ u64 protos)
++{
++ rdev->allowed_protocols[RC_FILTER_WAKEUP] = protos;
++}
++
++/* should be called prior to registration or with mutex held */
++static inline void rc_set_enabled_wakeup_protocols(struct rc_dev *rdev,
++ u64 protos)
++{
++ rdev->enabled_protocols[RC_FILTER_WAKEUP] = protos;
++}
++
+ /*
+ * From rc-main.c
+ * Those functions can be used on any type of Remote Controller. They