aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2013-03-06 14:52:05 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-23 10:25:54 -0400
commit9719afae5e589b409e137c36f89073d134f0de33 (patch)
tree62d24aef194d46c95e607828902cd1c13bd2c0c8
parentefa914d7d05e69013054710e6aacaf225b8fc2a2 (diff)
[media] rc-core: don't treat dev->rc_map.rc_type as a bitmap
store_protocols() treats dev->rc_map.rc_type as a bitmap which is wrong for two reasons. First of all, it is pretty bogus to change the protocol type of the keymap just because the hardware has been asked to decode a different protocol. Second, dev->rc_map.rc_type is an enum (i.e. a single protocol) as pointed out by James Hogan <james.hogan@imgtec.com>. Fix both issues by introducing a separate enabled_protocols member to struct rc_dev. Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c1
-rw-r--r--drivers/media/rc/ir-jvc-decoder.c2
-rw-r--r--drivers/media/rc/ir-lirc-codec.c2
-rw-r--r--drivers/media/rc/ir-mce_kbd-decoder.c2
-rw-r--r--drivers/media/rc/ir-nec-decoder.c2
-rw-r--r--drivers/media/rc/ir-raw.c2
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c6
-rw-r--r--drivers/media/rc/ir-rc5-sz-decoder.c2
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c2
-rw-r--r--drivers/media/rc/ir-sanyo-decoder.c2
-rw-r--r--drivers/media/rc/ir-sony-decoder.c8
-rw-r--r--drivers/media/rc/rc-core-priv.h1
-rw-r--r--drivers/media/rc/rc-main.c32
-rw-r--r--include/media/rc-core.h2
14 files changed, 28 insertions, 38 deletions
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 08ae067b2b6f..2586e46f14b5 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -423,6 +423,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
423 */ 423 */
424 rc->map_name = ir->ir_codes; 424 rc->map_name = ir->ir_codes;
425 rc->allowed_protos = rc_type; 425 rc->allowed_protos = rc_type;
426 rc->enabled_protocols = rc_type;
426 if (!rc->driver_name) 427 if (!rc->driver_name)
427 rc->driver_name = MODULE_NAME; 428 rc->driver_name = MODULE_NAME;
428 429
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c
index 69edffb9fe9a..3948138ca870 100644
--- a/drivers/media/rc/ir-jvc-decoder.c
+++ b/drivers/media/rc/ir-jvc-decoder.c
@@ -47,7 +47,7 @@ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev)
47{ 47{
48 struct jvc_dec *data = &dev->raw->jvc; 48 struct jvc_dec *data = &dev->raw->jvc;
49 49
50 if (!(dev->raw->enabled_protocols & RC_BIT_JVC)) 50 if (!(dev->enabled_protocols & RC_BIT_JVC))
51 return 0; 51 return 0;
52 52
53 if (!is_timing_event(ev)) { 53 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index 9945e5e7f61a..ff4d93d1907f 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -35,7 +35,7 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev)
35 struct lirc_codec *lirc = &dev->raw->lirc; 35 struct lirc_codec *lirc = &dev->raw->lirc;
36 int sample; 36 int sample;
37 37
38 if (!(dev->raw->enabled_protocols & RC_BIT_LIRC)) 38 if (!(dev->enabled_protocols & RC_BIT_LIRC))
39 return 0; 39 return 0;
40 40
41 if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf) 41 if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf)
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
index 33fafa4cf7cb..9f3c9b59f30c 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -216,7 +216,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
216 u32 scancode; 216 u32 scancode;
217 unsigned long delay; 217 unsigned long delay;
218 218
219 if (!(dev->raw->enabled_protocols & RC_BIT_MCE_KBD)) 219 if (!(dev->enabled_protocols & RC_BIT_MCE_KBD))
220 return 0; 220 return 0;
221 221
222 if (!is_timing_event(ev)) { 222 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index a47ee3634969..9a9009411439 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -52,7 +52,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
52 u8 address, not_address, command, not_command; 52 u8 address, not_address, command, not_command;
53 bool send_32bits = false; 53 bool send_32bits = false;
54 54
55 if (!(dev->raw->enabled_protocols & RC_BIT_NEC)) 55 if (!(dev->enabled_protocols & RC_BIT_NEC))
56 return 0; 56 return 0;
57 57
58 if (!is_timing_event(ev)) { 58 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 17c94be9f24c..5c42750c7b71 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -256,7 +256,7 @@ int ir_raw_event_register(struct rc_dev *dev)
256 return -ENOMEM; 256 return -ENOMEM;
257 257
258 dev->raw->dev = dev; 258 dev->raw->dev = dev;
259 dev->raw->enabled_protocols = ~0; 259 dev->enabled_protocols = ~0;
260 rc = kfifo_alloc(&dev->raw->kfifo, 260 rc = kfifo_alloc(&dev->raw->kfifo,
261 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE, 261 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE,
262 GFP_KERNEL); 262 GFP_KERNEL);
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index 5b4d1ddeac4e..4e53a319c5d8 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -52,7 +52,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
52 u8 toggle; 52 u8 toggle;
53 u32 scancode; 53 u32 scancode;
54 54
55 if (!(dev->raw->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X))) 55 if (!(dev->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X)))
56 return 0; 56 return 0;
57 57
58 if (!is_timing_event(ev)) { 58 if (!is_timing_event(ev)) {
@@ -128,7 +128,7 @@ again:
128 if (data->wanted_bits == RC5X_NBITS) { 128 if (data->wanted_bits == RC5X_NBITS) {
129 /* RC5X */ 129 /* RC5X */
130 u8 xdata, command, system; 130 u8 xdata, command, system;
131 if (!(dev->raw->enabled_protocols & RC_BIT_RC5X)) { 131 if (!(dev->enabled_protocols & RC_BIT_RC5X)) {
132 data->state = STATE_INACTIVE; 132 data->state = STATE_INACTIVE;
133 return 0; 133 return 0;
134 } 134 }
@@ -145,7 +145,7 @@ again:
145 } else { 145 } else {
146 /* RC5 */ 146 /* RC5 */
147 u8 command, system; 147 u8 command, system;
148 if (!(dev->raw->enabled_protocols & RC_BIT_RC5)) { 148 if (!(dev->enabled_protocols & RC_BIT_RC5)) {
149 data->state = STATE_INACTIVE; 149 data->state = STATE_INACTIVE;
150 return 0; 150 return 0;
151 } 151 }
diff --git a/drivers/media/rc/ir-rc5-sz-decoder.c b/drivers/media/rc/ir-rc5-sz-decoder.c
index fd807a8308d8..865fe84fd854 100644
--- a/drivers/media/rc/ir-rc5-sz-decoder.c
+++ b/drivers/media/rc/ir-rc5-sz-decoder.c
@@ -48,7 +48,7 @@ static int ir_rc5_sz_decode(struct rc_dev *dev, struct ir_raw_event ev)
48 u8 toggle, command, system; 48 u8 toggle, command, system;
49 u32 scancode; 49 u32 scancode;
50 50
51 if (!(dev->raw->enabled_protocols & RC_BIT_RC5_SZ)) 51 if (!(dev->enabled_protocols & RC_BIT_RC5_SZ))
52 return 0; 52 return 0;
53 53
54 if (!is_timing_event(ev)) { 54 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index e19072ffb36c..7cba7d33a3fa 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -89,7 +89,7 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
89 u32 scancode; 89 u32 scancode;
90 u8 toggle; 90 u8 toggle;
91 91
92 if (!(dev->raw->enabled_protocols & 92 if (!(dev->enabled_protocols &
93 (RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | 93 (RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 |
94 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE))) 94 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE)))
95 return 0; 95 return 0;
diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c
index 7e69a3b65370..0a06205b5677 100644
--- a/drivers/media/rc/ir-sanyo-decoder.c
+++ b/drivers/media/rc/ir-sanyo-decoder.c
@@ -58,7 +58,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
58 u32 scancode; 58 u32 scancode;
59 u8 address, command, not_command; 59 u8 address, command, not_command;
60 60
61 if (!(dev->raw->enabled_protocols & RC_BIT_SANYO)) 61 if (!(dev->enabled_protocols & RC_BIT_SANYO))
62 return 0; 62 return 0;
63 63
64 if (!is_timing_event(ev)) { 64 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c
index fb914342cf4d..29ab9c2db060 100644
--- a/drivers/media/rc/ir-sony-decoder.c
+++ b/drivers/media/rc/ir-sony-decoder.c
@@ -45,7 +45,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
45 u32 scancode; 45 u32 scancode;
46 u8 device, subdevice, function; 46 u8 device, subdevice, function;
47 47
48 if (!(dev->raw->enabled_protocols & 48 if (!(dev->enabled_protocols &
49 (RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20))) 49 (RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20)))
50 return 0; 50 return 0;
51 51
@@ -124,7 +124,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
124 124
125 switch (data->count) { 125 switch (data->count) {
126 case 12: 126 case 12:
127 if (!(dev->raw->enabled_protocols & RC_BIT_SONY12)) { 127 if (!(dev->enabled_protocols & RC_BIT_SONY12)) {
128 data->state = STATE_INACTIVE; 128 data->state = STATE_INACTIVE;
129 return 0; 129 return 0;
130 } 130 }
@@ -133,7 +133,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
133 function = bitrev8((data->bits >> 4) & 0xFE); 133 function = bitrev8((data->bits >> 4) & 0xFE);
134 break; 134 break;
135 case 15: 135 case 15:
136 if (!(dev->raw->enabled_protocols & RC_BIT_SONY15)) { 136 if (!(dev->enabled_protocols & RC_BIT_SONY15)) {
137 data->state = STATE_INACTIVE; 137 data->state = STATE_INACTIVE;
138 return 0; 138 return 0;
139 } 139 }
@@ -142,7 +142,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
142 function = bitrev8((data->bits >> 7) & 0xFE); 142 function = bitrev8((data->bits >> 7) & 0xFE);
143 break; 143 break;
144 case 20: 144 case 20:
145 if (!(dev->raw->enabled_protocols & RC_BIT_SONY20)) { 145 if (!(dev->enabled_protocols & RC_BIT_SONY20)) {
146 data->state = STATE_INACTIVE; 146 data->state = STATE_INACTIVE;
147 return 0; 147 return 0;
148 } 148 }
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 5d87287ed372..70a180bb0bd0 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -39,7 +39,6 @@ struct ir_raw_event_ctrl {
39 ktime_t last_event; /* when last event occurred */ 39 ktime_t last_event; /* when last event occurred */
40 enum raw_event_type last_type; /* last event type */ 40 enum raw_event_type last_type; /* last event type */
41 struct rc_dev *dev; /* pointer to the parent rc_dev */ 41 struct rc_dev *dev; /* pointer to the parent rc_dev */
42 u64 enabled_protocols; /* enabled raw protocol decoders */
43 42
44 /* raw decoder state follows */ 43 /* raw decoder state follows */
45 struct ir_raw_event prev_ev; 44 struct ir_raw_event prev_ev;
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index f3047920b8c0..1cf382a0b277 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -783,13 +783,12 @@ static ssize_t show_protocols(struct device *device,
783 783
784 mutex_lock(&dev->lock); 784 mutex_lock(&dev->lock);
785 785
786 if (dev->driver_type == RC_DRIVER_SCANCODE) { 786 enabled = dev->enabled_protocols;
787 enabled = dev->rc_map.rc_type; 787 if (dev->driver_type == RC_DRIVER_SCANCODE)
788 allowed = dev->allowed_protos; 788 allowed = dev->allowed_protos;
789 } else if (dev->raw) { 789 else if (dev->raw)
790 enabled = dev->raw->enabled_protocols;
791 allowed = ir_raw_get_allowed_protocols(); 790 allowed = ir_raw_get_allowed_protocols();
792 } else { 791 else {
793 mutex_unlock(&dev->lock); 792 mutex_unlock(&dev->lock);
794 return -ENODEV; 793 return -ENODEV;
795 } 794 }
@@ -847,7 +846,6 @@ static ssize_t store_protocols(struct device *device,
847 u64 type; 846 u64 type;
848 u64 mask; 847 u64 mask;
849 int rc, i, count = 0; 848 int rc, i, count = 0;
850 unsigned long flags;
851 ssize_t ret; 849 ssize_t ret;
852 850
853 /* Device is being removed */ 851 /* Device is being removed */
@@ -856,15 +854,12 @@ static ssize_t store_protocols(struct device *device,
856 854
857 mutex_lock(&dev->lock); 855 mutex_lock(&dev->lock);
858 856
859 if (dev->driver_type == RC_DRIVER_SCANCODE) 857 if (dev->driver_type != RC_DRIVER_SCANCODE && !dev->raw) {
860 type = dev->rc_map.rc_type;
861 else if (dev->raw)
862 type = dev->raw->enabled_protocols;
863 else {
864 IR_dprintk(1, "Protocol switching not supported\n"); 858 IR_dprintk(1, "Protocol switching not supported\n");
865 ret = -EINVAL; 859 ret = -EINVAL;
866 goto out; 860 goto out;
867 } 861 }
862 type = dev->enabled_protocols;
868 863
869 while ((tmp = strsep((char **) &data, " \n")) != NULL) { 864 while ((tmp = strsep((char **) &data, " \n")) != NULL) {
870 if (!*tmp) 865 if (!*tmp)
@@ -922,14 +917,7 @@ static ssize_t store_protocols(struct device *device,
922 } 917 }
923 } 918 }
924 919
925 if (dev->driver_type == RC_DRIVER_SCANCODE) { 920 dev->enabled_protocols = type;
926 spin_lock_irqsave(&dev->rc_map.lock, flags);
927 dev->rc_map.rc_type = type;
928 spin_unlock_irqrestore(&dev->rc_map.lock, flags);
929 } else {
930 dev->raw->enabled_protocols = type;
931 }
932
933 IR_dprintk(1, "Current protocol(s): 0x%llx\n", 921 IR_dprintk(1, "Current protocol(s): 0x%llx\n",
934 (long long)type); 922 (long long)type);
935 923
@@ -1068,9 +1056,8 @@ int rc_register_device(struct rc_dev *dev)
1068 /* 1056 /*
1069 * Take the lock here, as the device sysfs node will appear 1057 * Take the lock here, as the device sysfs node will appear
1070 * when device_add() is called, which may trigger an ir-keytable udev 1058 * when device_add() is called, which may trigger an ir-keytable udev
1071 * rule, which will in turn call show_protocols and access either 1059 * rule, which will in turn call show_protocols and access
1072 * dev->rc_map.rc_type or dev->raw->enabled_protocols before it has 1060 * dev->enabled_protocols before it has been initialized.
1073 * been initialized.
1074 */ 1061 */
1075 mutex_lock(&dev->lock); 1062 mutex_lock(&dev->lock);
1076 1063
@@ -1132,6 +1119,7 @@ int rc_register_device(struct rc_dev *dev)
1132 rc = dev->change_protocol(dev, &rc_type); 1119 rc = dev->change_protocol(dev, &rc_type);
1133 if (rc < 0) 1120 if (rc < 0)
1134 goto out_raw; 1121 goto out_raw;
1122 dev->enabled_protocols = rc_type;
1135 } 1123 }
1136 1124
1137 mutex_unlock(&dev->lock); 1125 mutex_unlock(&dev->lock);
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index f03445f3c767..06a75deff553 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -51,6 +51,7 @@ enum rc_driver_type {
51 * @driver_type: specifies if protocol decoding is done in hardware or software 51 * @driver_type: specifies if protocol decoding is done in hardware or software
52 * @idle: used to keep track of RX state 52 * @idle: used to keep track of RX state
53 * @allowed_protos: bitmask with the supported RC_BIT_* protocols 53 * @allowed_protos: bitmask with the supported RC_BIT_* protocols
54 * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols
54 * @scanmask: some hardware decoders are not capable of providing the full 55 * @scanmask: some hardware decoders are not capable of providing the full
55 * scancode to the application. As this is a hardware limit, we can't do 56 * scancode to the application. As this is a hardware limit, we can't do
56 * anything with it. Yet, as the same keycode table can be used with other 57 * anything with it. Yet, as the same keycode table can be used with other
@@ -99,6 +100,7 @@ struct rc_dev {
99 enum rc_driver_type driver_type; 100 enum rc_driver_type driver_type;
100 bool idle; 101 bool idle;
101 u64 allowed_protos; 102 u64 allowed_protos;
103 u64 enabled_protocols;
102 u32 scanmask; 104 u32 scanmask;
103 void *priv; 105 void *priv;
104 spinlock_t keylock; 106 spinlock_t keylock;