aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2016-09-19 18:21:23 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-09-22 10:44:52 -0400
commit00bb820755ed8ee996f076f193d2eadbfba50a2e (patch)
tree8e69e36976493c747e4708af57cba94a9ea973b6
parente998c92d6c70851cdc931a0ab5b6d4b554015955 (diff)
[media] rc: Hauppauge z8f0811 can decode RC6
The hardware does not decode the 16, 20 or 24 bit variety. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c90
-rw-r--r--drivers/media/pci/cx18/cx18-i2c.c3
-rw-r--r--drivers/media/pci/cx88/cx88-input.c3
-rw-r--r--drivers/media/pci/ivtv/ivtv-i2c.c3
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-i2c.c2
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c3
6 files changed, 69 insertions, 35 deletions
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index bf82726fd3f4..f95a6bc839d5 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -35,6 +35,7 @@
35 * 35 *
36 */ 36 */
37 37
38#include <asm/unaligned.h>
38#include <linux/module.h> 39#include <linux/module.h>
39#include <linux/init.h> 40#include <linux/init.h>
40#include <linux/kernel.h> 41#include <linux/kernel.h>
@@ -63,51 +64,80 @@ module_param(debug, int, 0644); /* debug level (0,1,2) */
63/* ----------------------------------------------------------------------- */ 64/* ----------------------------------------------------------------------- */
64 65
65static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol, 66static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol,
66 u32 *scancode, u8 *ptoggle, int size, int offset) 67 u32 *scancode, u8 *ptoggle, int size)
67{ 68{
68 unsigned char buf[6]; 69 unsigned char buf[6];
69 int start, range, toggle, dev, code, ircode; 70 int start, range, toggle, dev, code, ircode, vendor;
70 71
71 /* poll IR chip */ 72 /* poll IR chip */
72 if (size != i2c_master_recv(ir->c, buf, size)) 73 if (size != i2c_master_recv(ir->c, buf, size))
73 return -EIO; 74 return -EIO;
74 75
75 /* split rc5 data block ... */ 76 if (buf[0] & 0x80) {
76 start = (buf[offset] >> 7) & 1; 77 int offset = (size == 6) ? 3 : 0;
77 range = (buf[offset] >> 6) & 1;
78 toggle = (buf[offset] >> 5) & 1;
79 dev = buf[offset] & 0x1f;
80 code = (buf[offset+1] >> 2) & 0x3f;
81 78
82 /* rc5 has two start bits 79 /* split rc5 data block ... */
83 * the first bit must be one 80 start = (buf[offset] >> 7) & 1;
84 * the second bit defines the command range (1 = 0-63, 0 = 64 - 127) 81 range = (buf[offset] >> 6) & 1;
85 */ 82 toggle = (buf[offset] >> 5) & 1;
86 if (!start) 83 dev = buf[offset] & 0x1f;
87 /* no key pressed */ 84 code = (buf[offset+1] >> 2) & 0x3f;
88 return 0;
89 85
90 /* filter out invalid key presses */ 86 /* rc5 has two start bits
91 ircode = (start << 12) | (toggle << 11) | (dev << 6) | code; 87 * the first bit must be one
92 if ((ircode & 0x1fff) == 0x1fff) 88 * the second bit defines the command range:
93 return 0; 89 * 1 = 0-63, 0 = 64 - 127
90 */
91 if (!start)
92 /* no key pressed */
93 return 0;
94 94
95 if (!range) 95 /* filter out invalid key presses */
96 code += 64; 96 ircode = (start << 12) | (toggle << 11) | (dev << 6) | code;
97 if ((ircode & 0x1fff) == 0x1fff)
98 return 0;
97 99
98 dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n", 100 if (!range)
99 start, range, toggle, dev, code); 101 code += 64;
100 102
101 *protocol = RC_TYPE_RC5; 103 dprintk(1, "ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n",
102 *scancode = RC_SCANCODE_RC5(dev, code); 104 start, range, toggle, dev, code);
103 *ptoggle = toggle; 105
104 return 1; 106 *protocol = RC_TYPE_RC5;
107 *scancode = RC_SCANCODE_RC5(dev, code);
108 *ptoggle = toggle;
109
110 return 1;
111 } else if (size == 6 && (buf[0] & 0x40)) {
112 code = buf[4];
113 dev = buf[3];
114 vendor = get_unaligned_be16(buf + 1);
115
116 if (vendor == 0x800f) {
117 *ptoggle = (dev & 0x80) != 0;
118 *protocol = RC_TYPE_RC6_MCE;
119 dev &= 0x7f;
120 dprintk(1, "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n",
121 toggle, vendor, dev, code);
122 } else {
123 *ptoggle = 0;
124 *protocol = RC_TYPE_RC6_6A_32;
125 dprintk(1, "ir hauppauge (rc6-6a-32): vendor=%d dev=%d code=%d\n",
126 vendor, dev, code);
127 }
128
129 *scancode = RC_SCANCODE_RC6_6A(vendor, dev, code);
130
131 return 1;
132 }
133
134 return 0;
105} 135}
106 136
107static int get_key_haup(struct IR_i2c *ir, enum rc_type *protocol, 137static int get_key_haup(struct IR_i2c *ir, enum rc_type *protocol,
108 u32 *scancode, u8 *toggle) 138 u32 *scancode, u8 *toggle)
109{ 139{
110 return get_key_haup_common (ir, protocol, scancode, toggle, 3, 0); 140 return get_key_haup_common(ir, protocol, scancode, toggle, 3);
111} 141}
112 142
113static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol, 143static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol,
@@ -126,7 +156,7 @@ static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol,
126 if (ret != 1) 156 if (ret != 1)
127 return (ret < 0) ? ret : -EINVAL; 157 return (ret < 0) ? ret : -EINVAL;
128 158
129 return get_key_haup_common(ir, protocol, scancode, toggle, 6, 3); 159 return get_key_haup_common(ir, protocol, scancode, toggle, 6);
130} 160}
131 161
132static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol, 162static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol,
@@ -347,7 +377,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
347 case 0x71: 377 case 0x71:
348 name = "Hauppauge/Zilog Z8"; 378 name = "Hauppauge/Zilog Z8";
349 ir->get_key = get_key_haup_xvr; 379 ir->get_key = get_key_haup_xvr;
350 rc_type = RC_BIT_RC5; 380 rc_type = RC_BIT_RC5 | RC_BIT_RC6_MCE | RC_BIT_RC6_6A_32;
351 ir_codes = RC_MAP_HAUPPAUGE; 381 ir_codes = RC_MAP_HAUPPAUGE;
352 break; 382 break;
353 } 383 }
diff --git a/drivers/media/pci/cx18/cx18-i2c.c b/drivers/media/pci/cx18/cx18-i2c.c
index 4af8cd6df95d..c9329371a3f8 100644
--- a/drivers/media/pci/cx18/cx18-i2c.c
+++ b/drivers/media/pci/cx18/cx18-i2c.c
@@ -98,7 +98,8 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
98 case CX18_HW_Z8F0811_IR_RX_HAUP: 98 case CX18_HW_Z8F0811_IR_RX_HAUP:
99 init_data->ir_codes = RC_MAP_HAUPPAUGE; 99 init_data->ir_codes = RC_MAP_HAUPPAUGE;
100 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 100 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
101 init_data->type = RC_BIT_RC5; 101 init_data->type = RC_BIT_RC5 | RC_BIT_RC6_MCE |
102 RC_BIT_RC6_6A_32;
102 init_data->name = cx->card_name; 103 init_data->name = cx->card_name;
103 info.platform_data = init_data; 104 info.platform_data = init_data;
104 break; 105 break;
diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c
index 3f1342c98b46..21d029b2bbb3 100644
--- a/drivers/media/pci/cx88/cx88-input.c
+++ b/drivers/media/pci/cx88/cx88-input.c
@@ -631,7 +631,8 @@ void cx88_i2c_init_ir(struct cx88_core *core)
631 /* Hauppauge XVR */ 631 /* Hauppauge XVR */
632 core->init_data.name = "cx88 Hauppauge XVR remote"; 632 core->init_data.name = "cx88 Hauppauge XVR remote";
633 core->init_data.ir_codes = RC_MAP_HAUPPAUGE; 633 core->init_data.ir_codes = RC_MAP_HAUPPAUGE;
634 core->init_data.type = RC_BIT_RC5; 634 core->init_data.type = RC_BIT_RC5 | RC_BIT_RC6_MCE |
635 RC_BIT_RC6_6A_32;
635 core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 636 core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
636 637
637 info.platform_data = &core->init_data; 638 info.platform_data = &core->init_data;
diff --git a/drivers/media/pci/ivtv/ivtv-i2c.c b/drivers/media/pci/ivtv/ivtv-i2c.c
index dd57442cf086..dea80efd5836 100644
--- a/drivers/media/pci/ivtv/ivtv-i2c.c
+++ b/drivers/media/pci/ivtv/ivtv-i2c.c
@@ -215,7 +215,8 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
215 /* Default to grey remote */ 215 /* Default to grey remote */
216 init_data->ir_codes = RC_MAP_HAUPPAUGE; 216 init_data->ir_codes = RC_MAP_HAUPPAUGE;
217 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 217 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
218 init_data->type = RC_BIT_RC5; 218 init_data->type = RC_BIT_RC5 | RC_BIT_RC6_MCE |
219 RC_BIT_RC6_6A_32;
219 init_data->name = itv->card_name; 220 init_data->name = itv->card_name;
220 break; 221 break;
221 case IVTV_HW_I2C_IR_RX_ADAPTEC: 222 case IVTV_HW_I2C_IR_RX_ADAPTEC:
diff --git a/drivers/media/usb/hdpvr/hdpvr-i2c.c b/drivers/media/usb/hdpvr/hdpvr-i2c.c
index 608ae96dc0e5..9b641c4d4431 100644
--- a/drivers/media/usb/hdpvr/hdpvr-i2c.c
+++ b/drivers/media/usb/hdpvr/hdpvr-i2c.c
@@ -55,7 +55,7 @@ struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev)
55 /* Our default information for ir-kbd-i2c.c to use */ 55 /* Our default information for ir-kbd-i2c.c to use */
56 init_data->ir_codes = RC_MAP_HAUPPAUGE; 56 init_data->ir_codes = RC_MAP_HAUPPAUGE;
57 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 57 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
58 init_data->type = RC_BIT_RC5; 58 init_data->type = RC_BIT_RC5 | RC_BIT_RC6_MCE | RC_BIT_RC6_6A_32;
59 init_data->name = "HD-PVR"; 59 init_data->name = "HD-PVR";
60 init_data->polling_interval = 405; /* ms, duplicated from Windows */ 60 init_data->polling_interval = 405; /* ms, duplicated from Windows */
61 hdpvr_ir_rx_i2c_board_info.platform_data = init_data; 61 hdpvr_ir_rx_i2c_board_info.platform_data = init_data;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
index 14321d0a1833..6da5fb544817 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
@@ -596,7 +596,8 @@ static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw)
596 case PVR2_IR_SCHEME_24XXX_MCE: /* 24xxx MCE device */ 596 case PVR2_IR_SCHEME_24XXX_MCE: /* 24xxx MCE device */
597 init_data->ir_codes = RC_MAP_HAUPPAUGE; 597 init_data->ir_codes = RC_MAP_HAUPPAUGE;
598 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 598 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
599 init_data->type = RC_BIT_RC5; 599 init_data->type = RC_BIT_RC5 | RC_BIT_RC6_MCE |
600 RC_BIT_RC6_6A_32;
600 init_data->name = hdw->hdw_desc->description; 601 init_data->name = hdw->hdw_desc->description;
601 /* IR Receiver */ 602 /* IR Receiver */
602 info.addr = 0x71; 603 info.addr = 0x71;