diff options
author | Sean Young <sean@mess.org> | 2016-09-21 12:54:19 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-09-22 17:46:49 +0300 |
commit | 2ceeca0499d745213306ecd785af17adb2321b6a (patch) | |
tree | 7bd01f282f8fd67bdbd4a3828e1af6db34744a65 /drivers/media | |
parent | 00bb820755ed8ee996f076f193d2eadbfba50a2e (diff) | |
download | linux-2ceeca0499d745213306ecd785af17adb2321b6a.tar.xz |
[media] rc: split nec protocol into its three variants
Currently we do not know what variant (bit length) of the nec protocol
is used, other than from guessing from the length of the scancode. Now
nec will be handled the same way as the sony protocol or the rc6 protocol;
one variant per bit length.
In the future we might want to expose the rc protocol type to userspace
and we don't want to be introducing this world of pain into userspace
too.
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/pci/cx23885/cx23885-input.c | 2 | ||||
-rw-r--r-- | drivers/media/pci/cx88/cx88-input.c | 5 | ||||
-rw-r--r-- | drivers/media/pci/saa7134/saa7134-input.c | 4 | ||||
-rw-r--r-- | drivers/media/rc/igorplugusb.c | 3 | ||||
-rw-r--r-- | drivers/media/rc/img-ir/img-ir-nec.c | 6 | ||||
-rw-r--r-- | drivers/media/rc/ir-nec-decoder.c | 8 | ||||
-rw-r--r-- | drivers/media/rc/rc-main.c | 4 | ||||
-rw-r--r-- | drivers/media/usb/au0828/au0828-input.c | 3 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/af9015.c | 8 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/af9035.c | 9 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/az6007.c | 13 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/lmedm04.c | 5 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 9 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb/dib0700_core.c | 4 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb/dtt200u.c | 5 |
15 files changed, 62 insertions, 26 deletions
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c index 64328d08ac2f..410c3141c163 100644 --- a/drivers/media/pci/cx23885/cx23885-input.c +++ b/drivers/media/pci/cx23885/cx23885-input.c @@ -293,7 +293,7 @@ int cx23885_input_init(struct cx23885_dev *dev) case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: /* Integrated CX23885 IR controller */ driver_type = RC_DRIVER_IR_RAW; - allowed_protos = RC_BIT_NEC; + allowed_protos = RC_BIT_ALL; /* The grey Terratec remote with orange buttons */ rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS; break; diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c index 21d029b2bbb3..cd7687183381 100644 --- a/drivers/media/pci/cx88/cx88-input.c +++ b/drivers/media/pci/cx88/cx88-input.c @@ -144,7 +144,8 @@ static void cx88_ir_handle_key(struct cx88_IR *ir) scancode = RC_SCANCODE_NECX(addr, cmd); if (0 == (gpio & ir->mask_keyup)) - rc_keydown_notimeout(ir->dev, RC_TYPE_NEC, scancode, 0); + rc_keydown_notimeout(ir->dev, RC_TYPE_NECX, scancode, + 0); else rc_keyup(ir->dev); @@ -345,7 +346,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) * 002-T mini RC, provided with newer PV hardware */ ir_codes = RC_MAP_PIXELVIEW_MK12; - rc_type = RC_BIT_NEC; + rc_type = RC_BIT_NECX; ir->gpio_addr = MO_GP1_IO; ir->mask_keyup = 0x80; ir->polling = 10; /* ms */ diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c index c8042c3888cd..eff52bbbfd66 100644 --- a/drivers/media/pci/saa7134/saa7134-input.c +++ b/drivers/media/pci/saa7134/saa7134-input.c @@ -345,7 +345,7 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_type *protocol, if (data[9] != (unsigned char)(~data[8])) return 0; - *protocol = RC_TYPE_NEC; + *protocol = RC_TYPE_NECX; *scancode = RC_SCANCODE_NECX(data[11] << 8 | data[10], data[9]); *toggle = 0; return 1; @@ -1035,7 +1035,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) dev->init_data.name = "BeholdTV"; dev->init_data.get_key = get_key_beholdm6xx; dev->init_data.ir_codes = RC_MAP_BEHOLD; - dev->init_data.type = RC_BIT_NEC; + dev->init_data.type = RC_BIT_NECX; info.addr = 0x2d; break; case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: diff --git a/drivers/media/rc/igorplugusb.c b/drivers/media/rc/igorplugusb.c index e0c531fa01da..5cf983be07a2 100644 --- a/drivers/media/rc/igorplugusb.c +++ b/drivers/media/rc/igorplugusb.c @@ -203,7 +203,8 @@ static int igorplugusb_probe(struct usb_interface *intf, * This device can only store 36 pulses + spaces, which is not enough * for the NEC protocol and many others. */ - rc->allowed_protocols = RC_BIT_ALL & ~(RC_BIT_NEC | RC_BIT_RC6_6A_20 | + rc->allowed_protocols = RC_BIT_ALL & ~(RC_BIT_NEC | RC_BIT_NECX | + RC_BIT_NEC32 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SONY20 | RC_BIT_MCE_KBD | RC_BIT_SANYO); diff --git a/drivers/media/rc/img-ir/img-ir-nec.c b/drivers/media/rc/img-ir/img-ir-nec.c index 27a7ea8f1260..09314933ea08 100644 --- a/drivers/media/rc/img-ir/img-ir-nec.c +++ b/drivers/media/rc/img-ir/img-ir-nec.c @@ -34,19 +34,21 @@ static int img_ir_nec_scancode(int len, u64 raw, u64 enabled_protocols, bitrev8(addr_inv) << 16 | bitrev8(data) << 8 | bitrev8(data_inv); + request->protocol = RC_TYPE_NEC32; } else if ((addr_inv ^ addr) != 0xff) { /* Extended NEC */ /* scan encoding: AAaaDD */ request->scancode = addr << 16 | addr_inv << 8 | data; + request->protocol = RC_TYPE_NECX; } else { /* Normal NEC */ /* scan encoding: AADD */ request->scancode = addr << 8 | data; + request->protocol = RC_TYPE_NEC; } - request->protocol = RC_TYPE_NEC; return IMG_IR_SCANCODE; } @@ -109,7 +111,7 @@ static int img_ir_nec_filter(const struct rc_scancode_filter *in, * http://wiki.altium.com/display/ADOH/NEC+Infrared+Transmission+Protocol */ struct img_ir_decoder img_ir_nec = { - .type = RC_BIT_NEC, + .type = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32, .control = { .decoden = 1, .code_type = IMG_IR_CODETYPE_PULSEDIST, diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c index bea0d1eedee0..2a9d155548ab 100644 --- a/drivers/media/rc/ir-nec-decoder.c +++ b/drivers/media/rc/ir-nec-decoder.c @@ -49,6 +49,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev) { struct nec_dec *data = &dev->raw->nec; u32 scancode; + enum rc_type rc_type; u8 address, not_address, command, not_command; bool send_32bits = false; @@ -171,22 +172,25 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev) * least Apple and TiVo remotes */ scancode = data->bits; IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", scancode); + rc_type = RC_TYPE_NEC32; } else if ((address ^ not_address) != 0xff) { /* Extended NEC */ scancode = address << 16 | not_address << 8 | command; IR_dprintk(1, "NEC (Ext) scancode 0x%06x\n", scancode); + rc_type = RC_TYPE_NECX; } else { /* Normal NEC */ scancode = address << 8 | command; IR_dprintk(1, "NEC scancode 0x%04x\n", scancode); + rc_type = RC_TYPE_NEC; } if (data->is_nec_x) data->necx_repeat = true; - rc_keydown(dev, RC_TYPE_NEC, scancode, 0); + rc_keydown(dev, rc_type, scancode, 0); data->state = STATE_INACTIVE; return 0; } @@ -198,7 +202,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev) } static struct ir_raw_handler nec_handler = { - .protocols = RC_BIT_NEC, + .protocols = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32, .decode = ir_nec_decode, }; diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 26fd63bdf8e8..d9c1f2ff7119 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -795,7 +795,9 @@ static const struct { { RC_BIT_UNKNOWN, "unknown", NULL }, { RC_BIT_RC5 | RC_BIT_RC5X, "rc-5", "ir-rc5-decoder" }, - { RC_BIT_NEC, "nec", "ir-nec-decoder" }, + { RC_BIT_NEC | + RC_BIT_NECX | + RC_BIT_NEC32, "nec", "ir-nec-decoder" }, { RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c index 3d6687f0407d..1e66e7828d8f 100644 --- a/drivers/media/usb/au0828/au0828-input.c +++ b/drivers/media/usb/au0828/au0828-input.c @@ -344,7 +344,8 @@ int au0828_rc_register(struct au0828_dev *dev) rc->dev.parent = &dev->usbdev->dev; rc->driver_name = "au0828-input"; rc->driver_type = RC_DRIVER_IR_RAW; - rc->allowed_protocols = RC_BIT_NEC | RC_BIT_RC5; + rc->allowed_protocols = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | + RC_BIT_RC5; /* all done */ err = rc_register_device(rc); diff --git a/drivers/media/usb/dvb-usb-v2/af9015.c b/drivers/media/usb/dvb-usb-v2/af9015.c index 09e0f58f6bb7..941ceff9b268 100644 --- a/drivers/media/usb/dvb-usb-v2/af9015.c +++ b/drivers/media/usb/dvb-usb-v2/af9015.c @@ -1222,6 +1222,7 @@ static int af9015_rc_query(struct dvb_usb_device *d) /* Only process key if canary killed */ if (buf[16] != 0xff && buf[0] != 0x01) { + enum rc_type proto; dev_dbg(&d->udev->dev, "%s: key pressed %*ph\n", __func__, 4, buf + 12); @@ -1237,11 +1238,13 @@ static int af9015_rc_query(struct dvb_usb_device *d) /* NEC */ state->rc_keycode = RC_SCANCODE_NEC(buf[12], buf[14]); + proto = RC_TYPE_NEC; } else { /* NEC extended*/ state->rc_keycode = RC_SCANCODE_NECX(buf[12] << 8 | buf[13], buf[14]); + proto = RC_TYPE_NECX; } } else { /* 32 bit NEC */ @@ -1249,8 +1252,9 @@ static int af9015_rc_query(struct dvb_usb_device *d) buf[13] << 16 | buf[14] << 8 | buf[15]); + proto = RC_TYPE_NEC32; } - rc_keydown(d->rc_dev, RC_TYPE_NEC, state->rc_keycode, 0); + rc_keydown(d->rc_dev, proto, state->rc_keycode, 0); } else { dev_dbg(&d->udev->dev, "%s: no key press\n", __func__); /* Invalidate last keypress */ @@ -1317,7 +1321,7 @@ static int af9015_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) if (!rc->map_name) rc->map_name = RC_MAP_EMPTY; - rc->allowed_protos = RC_BIT_NEC; + rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32; rc->query = af9015_rc_query; rc->interval = 500; diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index ca018cd3fcd4..8961dd732522 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c @@ -1828,6 +1828,7 @@ static int af9035_rc_query(struct dvb_usb_device *d) { struct usb_interface *intf = d->intf; int ret; + enum rc_type proto; u32 key; u8 buf[4]; struct usb_req req = { CMD_IR_GET, 0, 0, NULL, 4, buf }; @@ -1842,19 +1843,22 @@ static int af9035_rc_query(struct dvb_usb_device *d) if ((buf[0] + buf[1]) == 0xff) { /* NEC standard 16bit */ key = RC_SCANCODE_NEC(buf[0], buf[2]); + proto = RC_TYPE_NEC; } else { /* NEC extended 24bit */ key = RC_SCANCODE_NECX(buf[0] << 8 | buf[1], buf[2]); + proto = RC_TYPE_NECX; } } else { /* NEC full code 32bit */ key = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]); + proto = RC_TYPE_NEC32; } dev_dbg(&intf->dev, "%*ph\n", 4, buf); - rc_keydown(d->rc_dev, RC_TYPE_NEC, key, 0); + rc_keydown(d->rc_dev, proto, key, 0); return 0; @@ -1889,7 +1893,8 @@ static int af9035_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) switch (tmp) { case 0: /* NEC */ default: - rc->allowed_protos = RC_BIT_NEC; + rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX | + RC_BIT_NEC32; break; case 1: /* RC6 */ rc->allowed_protos = RC_BIT_RC6_MCE; diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c index 935dbaa80ef0..50c07fe7dacb 100644 --- a/drivers/media/usb/dvb-usb-v2/az6007.c +++ b/drivers/media/usb/dvb-usb-v2/az6007.c @@ -208,6 +208,7 @@ static int az6007_rc_query(struct dvb_usb_device *d) { struct az6007_device_state *st = d_to_priv(d); unsigned code; + enum rc_type proto; az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10); @@ -215,19 +216,23 @@ static int az6007_rc_query(struct dvb_usb_device *d) return 0; if ((st->data[3] ^ st->data[4]) == 0xff) { - if ((st->data[1] ^ st->data[2]) == 0xff) + if ((st->data[1] ^ st->data[2]) == 0xff) { code = RC_SCANCODE_NEC(st->data[1], st->data[3]); - else + proto = RC_TYPE_NEC; + } else { code = RC_SCANCODE_NECX(st->data[1] << 8 | st->data[2], st->data[3]); + proto = RC_TYPE_NECX; + } } else { code = RC_SCANCODE_NEC32(st->data[1] << 24 | st->data[2] << 16 | st->data[3] << 8 | st->data[4]); + proto = RC_TYPE_NEC32; } - rc_keydown(d->rc_dev, RC_TYPE_NEC, code, st->data[5]); + rc_keydown(d->rc_dev, proto, code, st->data[5]); return 0; } @@ -236,7 +241,7 @@ static int az6007_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) { pr_debug("Getting az6007 Remote Control properties\n"); - rc->allowed_protos = RC_BIT_NEC; + rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32; rc->query = az6007_rc_query; rc->interval = 400; diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index 3721ee63b8fb..0e8fb89896c4 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -357,7 +357,8 @@ static void lme2510_int_response(struct urb *lme_urb) ibuf[5]); deb_info(1, "INT Key = 0x%08x", key); - rc_keydown(adap_to_d(adap)->rc_dev, RC_TYPE_NEC, key, 0); + rc_keydown(adap_to_d(adap)->rc_dev, RC_TYPE_NEC32, key, + 0); break; case 0xbb: switch (st->tuner_config) { @@ -1242,7 +1243,7 @@ static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type, static int lme2510_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) { - rc->allowed_protos = RC_BIT_NEC; + rc->allowed_protos = RC_BIT_NEC32; return 0; } diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 6643762a9ff7..c583c638e468 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1631,22 +1631,27 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d) goto err; if (buf[4] & 0x01) { + enum rc_type proto; + if (buf[2] == (u8) ~buf[3]) { if (buf[0] == (u8) ~buf[1]) { /* NEC standard (16 bit) */ rc_code = RC_SCANCODE_NEC(buf[0], buf[2]); + proto = RC_TYPE_NEC; } else { /* NEC extended (24 bit) */ rc_code = RC_SCANCODE_NECX(buf[0] << 8 | buf[1], buf[2]); + proto = RC_TYPE_NECX; } } else { /* NEC full (32 bit) */ rc_code = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]); + proto = RC_TYPE_NEC32; } - rc_keydown(d->rc_dev, RC_TYPE_NEC, rc_code, 0); + rc_keydown(d->rc_dev, proto, rc_code, 0); ret = rtl28xxu_wr_reg(d, SYS_IRRC_SR, 1); if (ret) @@ -1668,7 +1673,7 @@ static int rtl2831u_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) { rc->map_name = RC_MAP_EMPTY; - rc->allowed_protos = RC_BIT_NEC; + rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32; rc->query = rtl2831u_rc_query; rc->interval = 400; diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c index 26797979ebce..f3196658fb70 100644 --- a/drivers/media/usb/dvb-usb/dib0700_core.c +++ b/drivers/media/usb/dvb-usb/dib0700_core.c @@ -710,7 +710,6 @@ static void dib0700_rc_urb_completion(struct urb *purb) switch (d->props.rc.core.protocol) { case RC_BIT_NEC: - protocol = RC_TYPE_NEC; toggle = 0; /* NEC protocol sends repeat code as 0 0 0 FF */ @@ -728,16 +727,19 @@ static void dib0700_rc_urb_completion(struct urb *purb) poll_reply->nec.not_system << 16 | poll_reply->nec.data << 8 | poll_reply->nec.not_data); + protocol = RC_TYPE_NEC32; } else if ((poll_reply->nec.system ^ poll_reply->nec.not_system) != 0xff) { deb_data("NEC extended protocol\n"); keycode = RC_SCANCODE_NECX(poll_reply->nec.system << 8 | poll_reply->nec.not_system, poll_reply->nec.data); + protocol = RC_TYPE_NECX; } else { deb_data("NEC normal protocol\n"); keycode = RC_SCANCODE_NEC(poll_reply->nec.system, poll_reply->nec.data); + protocol = RC_TYPE_NEC; } break; diff --git a/drivers/media/usb/dvb-usb/dtt200u.c b/drivers/media/usb/dvb-usb/dtt200u.c index be633ece4194..d2a01b50af0d 100644 --- a/drivers/media/usb/dvb-usb/dtt200u.c +++ b/drivers/media/usb/dvb-usb/dtt200u.c @@ -62,18 +62,21 @@ static int dtt200u_rc_query(struct dvb_usb_device *d) dvb_usb_generic_rw(d,&cmd,1,key,5,0); if (key[0] == 1) { + enum rc_type proto = RC_TYPE_NEC; + scancode = key[1]; if ((u8) ~key[1] != key[2]) { /* Extended NEC */ scancode = scancode << 8; scancode |= key[2]; + proto = RC_TYPE_NECX; } scancode = scancode << 8; scancode |= key[3]; /* Check command checksum is ok */ if ((u8) ~key[3] == key[4]) - rc_keydown(d->rc_dev, RC_TYPE_NEC, scancode, 0); + rc_keydown(d->rc_dev, proto, scancode, 0); else rc_keyup(d->rc_dev); } else if (key[0] == 2) { |