Skip to contentSkip to conversation

rc: filter out not allowed protocols when decoding

RFC PATCH In review Du, Changbin 2 participants 5 messages Sep 1, 2012 – Sep 6, 2012 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 rc: filter out not allowed protocols when decoding

From: "Du, Changbin" <[email protected]>

Each rc-raw device has a property "allowed_protos" stored in structure ir_raw_event_ctrl. But it didn't work because all decoders would be called when decoding. This path makes only allowed protocol decoders been invoked.

---
 drivers/media/rc/ir-raw.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/media/rc/ir-raw.c +6 -2
index a820251..198b6d8 100644
@@ -63,8 +63,12 @@ static int ir_raw_event_thread(void *data)
 		spin_unlock_irq(&raw->lock);
 
 		mutex_lock(&ir_raw_handler_lock);
-		list_for_each_entry(handler, &ir_raw_handler_list, list)
-			handler->decode(raw->dev, ev);
+		list_for_each_entry(handler, &ir_raw_handler_list, list) {
+			/* use all protocol by default */
+			if (raw->dev->allowed_protos == RC_TYPE_UNKNOWN ||
+			    raw->dev->allowed_protos & handler->protocols)
+				handler->decode(raw->dev, ev);
+		}
 		raw->prev_ev = ev;
 		mutex_unlock(&ir_raw_handler_lock);
 	}
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 18 lines · Changbin

From: "Du, Changbin" <[email protected]>

Each rc-raw device has a property "allowed_protos" stored in structure ir_raw_event_ctrl. But it didn't work because all decoders would be called when decoding. This path makes only allowed protocol decoders been invoked.

---
 drivers/media/rc/ir-raw.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/media/rc/ir-raw.c +0 -0
index a820251..198b6d8 100644
@@ -63,8 +63,12 @@ static int ir_raw_event_thread(void *data)
 		spin_unlock_irq(&raw->lock);

drivers/media/rc/ir-raw.c static int ir_raw_event_thread(void *data) · line 71

Quoted 10 lines
drivers/media/rc/ir-raw.c +6 -2
 
 		mutex_lock(&ir_raw_handler_lock);
-		list_for_each_entry(handler, &ir_raw_handler_list, list)
-			handler->decode(raw->dev, ev);
+		list_for_each_entry(handler, &ir_raw_handler_list, list) {
+			/* use all protocol by default */
+			if (raw->dev->allowed_protos == RC_TYPE_UNKNOWN ||
+			    raw->dev->allowed_protos & handler->protocols)
+				handler->decode(raw->dev, ev);
+		}

Each IR protocol decoder already checks whether it is enabled or not; should it not be so that only allowed protocols can be enabled rather than checking both enabled_protocols and allowed_protocols?

Just from reading store_protocols it looks like decoders which aren't in allowed_protocols can be enabled, which makes no sense. Also ir_raw_event_register all protocols are enabled rather than the allowed ones.

Lastely I don't know why raw ir drivers should dictate which protocols can be enabled. Would it not be better to remove it entirely?

Quoted 10 lines
drivers/media/rc/ir-raw.c +0 -0
 		raw->prev_ev = ev;
 		mutex_unlock(&ir_raw_handler_lock);
 	}
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
In reply to a message not in the archive
Quoted 14 lines

drivers/media/rc/ir-raw.c static int ir_raw_event_thread(void *data) · line 71

Quoted 9 lines
              mutex_lock(&ir_raw_handler_lock);
drivers/media/rc/ir-raw.c +6 -2
-             list_for_each_entry(handler, &ir_raw_handler_list, list)
-                     handler->decode(raw->dev, ev);
+             list_for_each_entry(handler, &ir_raw_handler_list, list) {
+                     /* use all protocol by default */
+                     if (raw->dev->allowed_protos == RC_TYPE_UNKNOWN ||
+                         raw->dev->allowed_protos & handler->protocols)
+                             handler->decode(raw->dev, ev);
+             }

Each IR protocol decoder already checks whether it is enabled or not; should it not be so that only allowed protocols can be enabled rather than checking both enabled_protocols and allowed_protocols?

Quoted 8 lines

Just from reading store_protocols it looks like decoders which aren't in allowed_protocols can be enabled, which makes no sense. Also ir_raw_event_register all protocols are enabled rather than the allowed ones.

Lastely I don't know why raw ir drivers should dictate which protocols can be enabled. Would it not be better to remove it entirely?

I agree with you. I just thought that the only thing a decoder should care is its decoding logic, but not including decoder management. My idaea is:
1) use enabled_protocols to select decoders in ir_raw.c, but not
placed in decoders to do the judgement.
2) remove allowed_protocols or just use it to set the default
decoder (also should rename allowed_protocols to default_protocol).

I also have a question:
Is there a requirement that one more decoders are enabled for a
IR device at the same time?
And if that will lead to a issue that each decoder may decode a
same pulse sequence to different evnets since their protocol is different?

[Du, Changbin]

Quoted 12 lines
Quoted 12 lines

              raw->prev_ev = ev;
              mutex_unlock(&ir_raw_handler_lock);
      }

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#4 lore raw
Quoted 24 lines · Changbin Du
Quoted 14 lines

drivers/media/rc/ir-raw.c static int ir_raw_event_thread(void *data) · line 71

Quoted 9 lines
              mutex_lock(&ir_raw_handler_lock);
drivers/media/rc/ir-raw.c +6 -2
-             list_for_each_entry(handler, &ir_raw_handler_list, list)
-                     handler->decode(raw->dev, ev);
+             list_for_each_entry(handler, &ir_raw_handler_list, list) {
+                     /* use all protocol by default */
+                     if (raw->dev->allowed_protos == RC_TYPE_UNKNOWN ||
+                         raw->dev->allowed_protos & handler->protocols)
+                             handler->decode(raw->dev, ev);
+             }

Each IR protocol decoder already checks whether it is enabled or not; should it not be so that only allowed protocols can be enabled rather than checking both enabled_protocols and allowed_protocols?

Quoted 8 lines

Just from reading store_protocols it looks like decoders which aren't in allowed_protocols can be enabled, which makes no sense. Also ir_raw_event_register all protocols are enabled rather than the allowed ones.

Lastely I don't know why raw ir drivers should dictate which protocols can be enabled. Would it not be better to remove it entirely?

Quoted 6 lines

I agree with you. I just thought that the only thing a decoder should care is its decoding logic, but not including decoder management. My idaea is:
1) use enabled_protocols to select decoders in ir_raw.c, but not
placed in decoders to do the judgement.
2) remove allowed_protocols or just use it to set the default
decoder (also should rename allowed_protocols to default_protocol).

The default decoder should be the one set by the rc keymap.

Quoted 3 lines

I also have a question:
Is there a requirement that one more decoders are enabled for a
IR device at the same time?

Yes, you want to be able to multiple remotes on the IR device (which you can do as long as the scancodes don't overlap, I think), and the lirc device is implemented as a decoder, so you might want to see the raw IR as well as have it decoded.

Quoted 3 lines

And if that will lead to a issue that each decoder may decode a
same pulse sequence to different evnets since their protocol is different?

At the moment, no. David Hardeman has sent a patch for this:

http://patchwork.linuxtv.org/patch/11388/

Sean

#5 lore raw

Sean , many thanks for your help. I know much more about IR framwork now. I'll try to
work out a patch to remove "allowed_protocols".

Thanks again!
[Du, Changbin]

2012/9/4 Sean Young <[email protected]>:

Quoted 53 lines · Changbin Du
Quoted 24 lines
Quoted 14 lines

drivers/media/rc/ir-raw.c static int ir_raw_event_thread(void *data) · line 71

Quoted 9 lines
              mutex_lock(&ir_raw_handler_lock);
drivers/media/rc/ir-raw.c +6 -2
-             list_for_each_entry(handler, &ir_raw_handler_list, list)
-                     handler->decode(raw->dev, ev);
+             list_for_each_entry(handler, &ir_raw_handler_list, list) {
+                     /* use all protocol by default */
+                     if (raw->dev->allowed_protos == RC_TYPE_UNKNOWN ||
+                         raw->dev->allowed_protos & handler->protocols)
+                             handler->decode(raw->dev, ev);
+             }

Each IR protocol decoder already checks whether it is enabled or not; should it not be so that only allowed protocols can be enabled rather than checking both enabled_protocols and allowed_protocols?

Quoted 8 lines

Just from reading store_protocols it looks like decoders which aren't in allowed_protocols can be enabled, which makes no sense. Also ir_raw_event_register all protocols are enabled rather than the allowed ones.

Lastely I don't know why raw ir drivers should dictate which protocols can be enabled. Would it not be better to remove it entirely?

Quoted 6 lines

I agree with you. I just thought that the only thing a decoder should care is its decoding logic, but not including decoder management. My idaea is:
1) use enabled_protocols to select decoders in ir_raw.c, but not
placed in decoders to do the judgement.
2) remove allowed_protocols or just use it to set the default
decoder (also should rename allowed_protocols to default_protocol).

The default decoder should be the one set by the rc keymap.

Quoted 3 lines

I also have a question:
Is there a requirement that one more decoders are enabled for a
IR device at the same time?

Yes, you want to be able to multiple remotes on the IR device (which you can do as long as the scancodes don't overlap, I think), and the lirc device is implemented as a decoder, so you might want to see the raw IR as well as have it decoded.

Quoted 3 lines

And if that will lead to a issue that each decoder may decode a
same pulse sequence to different evnets since their protocol is different?

At the moment, no. David Hardeman has sent a patch for this:

http://patchwork.linuxtv.org/patch/11388/

Sean