This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: cec-ctl: add --ignore option
Author:  Hans Verkuil <hans.verk...@cisco.com>
Date:    Sun Dec 3 17:53:46 2017 +0100

This new option makes it possible to ignore messages from selected
logical addresses and with selected opcodes during monitoring.

Especially useful if one CEC device spams the bus with periodic
messages.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>

 utils/cec-ctl/cec-ctl.1.in | 65 +++++++++++++++++++++-------------------
 utils/cec-ctl/cec-ctl.cpp  | 74 ++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 100 insertions(+), 39 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=1864eb9d5908f87d3922ef627cb6bdd096a77edc
diff --git a/utils/cec-ctl/cec-ctl.1.in b/utils/cec-ctl/cec-ctl.1.in
index 04c1ccfe03bc..56764a428e32 100644
--- a/utils/cec-ctl/cec-ctl.1.in
+++ b/utils/cec-ctl/cec-ctl.1.in
@@ -33,36 +33,6 @@ Use this vendor ID. The vendor ID is a number from 0x0 to 
0xffffff.
 \fB\-C\fR, \fB\-\-clear\fR
 Clear all logical addresses, leaving the CEC device unconfigured.
 .TP
-\fB\-m\fR, \fB\-\-monitor\fR
-Start monitoring CEC traffic. This will monitor broadcast messages,
-messages directed to this CEC adapter and messages transmitted by this
-CEC adapter. Directed messages between other CEC devices are not
-monitored. This option requires root.
-.TP
-\fB\-M\fR, \fB\-\-monitor\-all\fR
-Start monitoring all CEC traffic. This will monitor all CEC messages,
-including directed messages between other CEC devices. This option requires 
root.
-Not all CEC devices support this monitoring mode. It will fallback to regular
-monitoring mode if it is not supported.
-.TP
-\fB\-\-monitor\-pin\fR
-Start monitoring and analyzing the low-level CEC pin transitions. This is only
-possible if the device has the CEC_CAP_MONITOR_PIN capability. This option 
requires root.
-When in pin monitoring mode all 0->1 and 1->0 CEC pin transitions are 
monitored and
-analysed. This is effectively a cheap CEC bus analyzer.
-.TP
-\fB\-\-monitor\-time\fR=\fI<secs>\fR
-Monitor for the given number of seconds, then exit. The default (0) is to 
monitor
-forever.
-.TP
-\fB\-\-store\-pin\fR=\fI<to>\fR
-Store the CEC pin events to the given file. This can be read and analyzed later
-via the \fB\-\-analyze\-pin\fR option. Use \- to write to stdout instead of to 
a file.
-.TP
-\fB\-\-analyze\-pin\fR=\fI<from>\fR
-Read and analyze the CEC pin events from the given file. Use \- to read from 
stdin
-instead of from a file.
-.TP
 \fB\-n\fR, \fB\-\-no\-reply\fR
 By default when sending a CEC message that expects a reply this utility will
 wait for that reply. With this option it will just send it without waiting
@@ -190,6 +160,41 @@ Signal that the RC source has a Media Top Menu.
 \fB\-\-rc\-src\-media\-context\fR
 Signal that the RC source has a Media Context Menu.
 .TP
+\fB\-m\fR, \fB\-\-monitor\fR
+Start monitoring CEC traffic. This will monitor broadcast messages,
+messages directed to this CEC adapter and messages transmitted by this
+CEC adapter. Directed messages between other CEC devices are not
+monitored. This option requires root.
+.TP
+\fB\-M\fR, \fB\-\-monitor\-all\fR
+Start monitoring all CEC traffic. This will monitor all CEC messages,
+including directed messages between other CEC devices. This option requires 
root.
+Not all CEC devices support this monitoring mode. It will fallback to regular
+monitoring mode if it is not supported.
+.TP
+\fB\-\-monitor\-pin\fR
+Start monitoring and analyzing the low-level CEC pin transitions. This is only
+possible if the device has the CEC_CAP_MONITOR_PIN capability. This option 
requires root.
+When in pin monitoring mode all 0->1 and 1->0 CEC pin transitions are 
monitored and
+analysed. This is effectively a cheap CEC bus analyzer.
+.TP
+\fB\-\-monitor\-time\fR=\fI<secs>\fR
+Monitor for the given number of seconds, then exit. The default (0) is to 
monitor
+forever.
+.TP
+\fB\-\-ignore\fR=\fI<la>\fR,\fI<opcode>\fR
+Ignore messages from logical address <la> and opcode <opcode> when monitoring.
+"all" can be used for <la> or <opcode> to match all logical addresses or 
opcodes.
+To ignore poll messages use "poll" as <opcode>.
+.TP
+\fB\-\-store\-pin\fR=\fI<to>\fR
+Store the CEC pin events to the given file. This can be read and analyzed later
+via the \fB\-\-analyze\-pin\fR option. Use \- to write to stdout instead of to 
a file.
+.TP
+\fB\-\-analyze\-pin\fR=\fI<from>\fR
+Read and analyze the CEC pin events from the given file. Use \- to read from 
stdin
+instead of from a file.
+.TP
 \fB\-\-help\-all\fR
 Prints the help message for all options.
 .TP
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index 5b1873a12194..3f49666323fe 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -53,6 +53,10 @@
 
 static struct timespec start_monotonic;
 static struct timeval start_timeofday;
+static bool ignore_la[16];
+
+#define POLL_FAKE_OPCODE 256
+static unsigned short ignore_opcode[257];
 
 struct cec_enum_values {
        const char *type_name;
@@ -679,6 +683,7 @@ enum Option {
        OptTimeout,
        OptMonitorTime,
        OptMonitorPin,
+       OptIgnore,
        OptStorePin,
        OptAnalyzePin,
        OptListUICommands,
@@ -747,6 +752,7 @@ static struct option long_options[] = {
        { "monitor-all", no_argument, 0, OptMonitorAll },
        { "monitor-pin", no_argument, 0, OptMonitorPin },
        { "monitor-time", required_argument, 0, OptMonitorTime },
+       { "ignore", required_argument, 0, OptIgnore },
        { "store-pin", required_argument, 0, OptStorePin },
        { "analyze-pin", required_argument, 0, OptAnalyzePin },
        { "no-reply", no_argument, 0, OptNoReply },
@@ -803,14 +809,6 @@ static void usage(void)
               "  -o, --osd-name=<name>    Use this OSD name\n"
               "  -V, --vendor-id=<id>     Use this vendor ID\n"
               "  -C, --clear              Clear all logical addresses\n"
-              "  -m, --monitor            Monitor CEC traffic\n"
-              "  -M, --monitor-all        Monitor all CEC traffic\n"
-              "  --monitor-pin            Monitor low-level CEC pin\n"
-              "  --monitor-time=<secs>    Monitor for <secs> seconds (default 
is forever)\n"
-              "  --store-pin=<to>         Store the low-level CEC pin changes 
to the file <to>.\n"
-              "                           Use - for stdout.\n"
-              "  --analyze-pin=<from>     Analyze the low-level CEC pin 
changes from the file <from>.\n"
-              "                           Use - for stdin.\n"
               "  -n, --no-reply           Don't wait for a reply\n"
               "  -t, --to=<la>            Send message to the given logical 
address\n"
               "  -f, --from=<la>          Send message from the given logical 
address\n"
@@ -860,6 +858,19 @@ static void usage(void)
               "  --rc-src-media-top       Signal that the RC source has a 
Media Top Menu\n"
               "  --rc-src-media-context   Signal that the RC source has a 
Media Context Menu\n"
               "\n"
+              "  -m, --monitor            Monitor CEC traffic\n"
+              "  -M, --monitor-all        Monitor all CEC traffic\n"
+              "  --monitor-pin            Monitor low-level CEC pin\n"
+              "  --monitor-time=<secs>    Monitor for <secs> seconds (default 
is forever)\n"
+              "  --ignore=<la>,<opcode>   Ignore messages from logical address 
<la> and opcode\n"
+              "                           <opcode> when monitoring. 'all' can 
be used for <la>\n"
+              "                           or <opcode> to match all logical 
addresses or opcodes.\n"
+              "                           To ignore poll messages use 'poll' 
as <opcode>.\n"
+              "  --store-pin=<to>         Store the low-level CEC pin changes 
to the file <to>.\n"
+              "                           Use - for stdout.\n"
+              "  --analyze-pin=<from>     Analyze the low-level CEC pin 
changes from the file <from>.\n"
+              "                           Use - for stdin.\n"
+              "\n"
               CEC_USAGE
               );
 }
@@ -1430,9 +1441,14 @@ static void monitor(struct node &node, __u32 
monitor_time, const char *store_pin
                        }
                        if (res || fstore == stdout)
                                continue;
-
                        from = cec_msg_initiator(&msg);
                        to = cec_msg_destination(&msg);
+                       if (ignore_la[from])
+                               continue;
+                       if ((msg.len == 1 && (ignore_opcode[POLL_FAKE_OPCODE] & 
(1 << from))) ||
+                           (msg.len > 1 && (ignore_opcode[msg.msg[1]] & (1 << 
from))))
+                               continue;
+
                        bool transmitted = msg.tx_status != 0;
                        printf("%s %s to %s (%d to %d): ",
                               transmitted ? "Transmitted by" : "Received from",
@@ -1734,6 +1750,46 @@ int main(int argc, char **argv)
                case OptMonitorTime:
                        monitor_time = strtoul(optarg, NULL, 0);
                        break;
+               case OptIgnore: {
+                       bool all_la = !strncmp(optarg, "all", 3);
+                       bool all_opcodes = true;
+                       const char *sep = strchr(optarg, ',');
+                       unsigned la_mask = 0xffff, opcode, la = 0;
+
+                       if (sep)
+                               all_opcodes = !strncmp(sep + 1, "all", 3);
+                       if (!all_la) {
+                               la = strtoul(optarg, NULL, 0);
+
+                               if (la > 15) {
+                                       fprintf(stderr, "invalid logical 
address (> 15)\n");
+                                       usage();
+                                       return 1;
+                               }
+                               la_mask = 1 << la;
+                       }
+                       if (!all_opcodes) {
+                               if (!strncmp(sep + 1, "poll", 4)) {
+                                       opcode = POLL_FAKE_OPCODE;
+                               } else {
+                                       opcode = strtoul(sep + 1, NULL, 0);
+                                       if (opcode > 255) {
+                                               fprintf(stderr, "invalid opcode 
(> 255)\n");
+                                               usage();
+                                               return 1;
+                                       }
+                               }
+                               ignore_opcode[opcode] |= la_mask;
+                               break;
+                       }
+                       if (all_la && all_opcodes) {
+                               fprintf(stderr, "all,all is invalid\n");
+                               usage();
+                               return 1;
+                       }
+                       ignore_la[la] = true;
+                       break;
+               }
                case OptStorePin:
                        store_pin = optarg;
                        break;

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to