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: move status2s functions to cec-info.cpp
Author:  Hans Verkuil <hans.verk...@cisco.com>
Date:    Thu Oct 4 12:57:55 2018 +0200

All three cec utilities used the same code to construct a string with
the message status. Move this code to cec-info.cpp and use it in all
three utilities.

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

 utils/cec-compliance/cec-compliance.cpp | 68 --------------------------------
 utils/cec-ctl/cec-ctl.cpp               | 68 --------------------------------
 utils/cec-follower/cec-follower.cpp     | 68 --------------------------------
 utils/common/cec-info.cpp               | 68 ++++++++++++++++++++++++++++++++
 utils/common/cec-info.h                 |  1 +
 utils/common/cec-log.cpp                | 69 +--------------------------------
 6 files changed, 70 insertions(+), 272 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=c926790d303bdf85c0b829e89a05ba40e9e795fd
diff --git a/utils/cec-compliance/cec-compliance.cpp 
b/utils/cec-compliance/cec-compliance.cpp
index ad6c5744c597..990c38bf1853 100644
--- a/utils/cec-compliance/cec-compliance.cpp
+++ b/utils/cec-compliance/cec-compliance.cpp
@@ -242,74 +242,6 @@ static std::string ts2s(__u64 ts)
        return s + "." + buf;
 }
 
-static std::string tx_status2s(const struct cec_msg &msg)
-{
-       std::string s;
-       char num[4];
-       unsigned stat = msg.tx_status;
-
-       if (stat)
-               s += "Tx";
-       if (stat & CEC_TX_STATUS_OK)
-               s += ", OK";
-       if (stat & CEC_TX_STATUS_ARB_LOST) {
-               sprintf(num, "%u", msg.tx_arb_lost_cnt);
-               s += ", Arbitration Lost";
-               if (msg.tx_arb_lost_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_NACK) {
-               sprintf(num, "%u", msg.tx_nack_cnt);
-               s += ", Not Acknowledged";
-               if (msg.tx_nack_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_LOW_DRIVE) {
-               sprintf(num, "%u", msg.tx_low_drive_cnt);
-               s += ", Low Drive";
-               if (msg.tx_low_drive_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_ERROR) {
-               sprintf(num, "%u", msg.tx_error_cnt);
-               s += ", Error";
-               if (msg.tx_error_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_MAX_RETRIES)
-               s += ", Max Retries";
-       return s;
-}
-
-static std::string rx_status2s(unsigned stat)
-{
-       std::string s;
-
-       if (stat)
-               s += "Rx";
-       if (stat & CEC_RX_STATUS_OK)
-               s += ", OK";
-       if (stat & CEC_RX_STATUS_TIMEOUT)
-               s += ", Timeout";
-       if (stat & CEC_RX_STATUS_FEATURE_ABORT)
-               s += ", Feature Abort";
-       return s;
-}
-
-std::string status2s(const struct cec_msg &msg)
-{
-       std::string s;
-
-       if (msg.tx_status)
-               s = tx_status2s(msg);
-       if (msg.rx_status) {
-               if (!s.empty())
-                       s += ", ";
-               s += rx_status2s(msg.rx_status);
-       }
-       return s;
-}
-
 const char *power_status2s(__u8 power_status)
 {
        switch (power_status) {
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index 10c5b27aeb94..126cfa08340b 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -359,74 +359,6 @@ static unsigned parse_phys_addr(const char *value)
 
 static char options[512];
 
-static std::string tx_status2s(const struct cec_msg &msg)
-{
-       std::string s;
-       char num[4];
-       unsigned stat = msg.tx_status;
-
-       if (stat)
-               s += "Tx";
-       if (stat & CEC_TX_STATUS_OK)
-               s += ", OK";
-       if (stat & CEC_TX_STATUS_ARB_LOST) {
-               sprintf(num, "%u", msg.tx_arb_lost_cnt);
-               s += ", Arbitration Lost";
-               if (msg.tx_arb_lost_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_NACK) {
-               sprintf(num, "%u", msg.tx_nack_cnt);
-               s += ", Not Acknowledged";
-               if (msg.tx_nack_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_LOW_DRIVE) {
-               sprintf(num, "%u", msg.tx_low_drive_cnt);
-               s += ", Low Drive";
-               if (msg.tx_low_drive_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_ERROR) {
-               sprintf(num, "%u", msg.tx_error_cnt);
-               s += ", Error";
-               if (msg.tx_error_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_MAX_RETRIES)
-               s += ", Max Retries";
-       return s;
-}
-
-static std::string rx_status2s(unsigned stat)
-{
-       std::string s;
-
-       if (stat)
-               s += "Rx";
-       if (stat & CEC_RX_STATUS_OK)
-               s += ", OK";
-       if (stat & CEC_RX_STATUS_TIMEOUT)
-               s += ", Timeout";
-       if (stat & CEC_RX_STATUS_FEATURE_ABORT)
-               s += ", Feature Abort";
-       return s;
-}
-
-static std::string status2s(const struct cec_msg &msg)
-{
-       std::string s;
-
-       if (msg.tx_status)
-               s = tx_status2s(msg);
-       if (msg.rx_status) {
-               if (!s.empty())
-                       s += ", ";
-               s += rx_status2s(msg.rx_status);
-       }
-       return s;
-}
-
 static void log_arg(const struct arg *arg, const char *arg_name, __u32 val)
 {
        unsigned i;
diff --git a/utils/cec-follower/cec-follower.cpp 
b/utils/cec-follower/cec-follower.cpp
index ca275dbb3942..9dbcd227a809 100644
--- a/utils/cec-follower/cec-follower.cpp
+++ b/utils/cec-follower/cec-follower.cpp
@@ -80,74 +80,6 @@ static void usage(void)
               );
 }
 
-static std::string tx_status2s(const struct cec_msg &msg)
-{
-       std::string s;
-       char num[4];
-       unsigned stat = msg.tx_status;
-
-       if (stat)
-               s += "Tx";
-       if (stat & CEC_TX_STATUS_OK)
-               s += ", OK";
-       if (stat & CEC_TX_STATUS_ARB_LOST) {
-               sprintf(num, "%u", msg.tx_arb_lost_cnt);
-               s += ", Arbitration Lost";
-               if (msg.tx_arb_lost_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_NACK) {
-               sprintf(num, "%u", msg.tx_nack_cnt);
-               s += ", Not Acknowledged";
-               if (msg.tx_nack_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_LOW_DRIVE) {
-               sprintf(num, "%u", msg.tx_low_drive_cnt);
-               s += ", Low Drive";
-               if (msg.tx_low_drive_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_ERROR) {
-               sprintf(num, "%u", msg.tx_error_cnt);
-               s += ", Error";
-               if (msg.tx_error_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_MAX_RETRIES)
-               s += ", Max Retries";
-       return s;
-}
-
-static std::string rx_status2s(unsigned stat)
-{
-       std::string s;
-
-       if (stat)
-               s += "Rx";
-       if (stat & CEC_RX_STATUS_OK)
-               s += ", OK";
-       if (stat & CEC_RX_STATUS_TIMEOUT)
-               s += ", Timeout";
-       if (stat & CEC_RX_STATUS_FEATURE_ABORT)
-               s += ", Feature Abort";
-       return s;
-}
-
-std::string status2s(const struct cec_msg &msg)
-{
-       std::string s;
-
-       if (msg.tx_status)
-               s = tx_status2s(msg);
-       if (msg.rx_status) {
-               if (!s.empty())
-                       s += ", ";
-               s += rx_status2s(msg.rx_status);
-       }
-       return s;
-}
-
 void sad_encode(const struct short_audio_desc *sad, __u32 *descriptor)
 {
        __u8 b1, b2, b3 = 0;
diff --git a/utils/common/cec-info.cpp b/utils/common/cec-info.cpp
index b2fe933d9556..00cd6c1645d1 100644
--- a/utils/common/cec-info.cpp
+++ b/utils/common/cec-info.cpp
@@ -279,6 +279,74 @@ std::string dev_feat2s(unsigned feat, const std::string 
&prefix)
        return s;
 }
 
+static std::string tx_status2s(const struct cec_msg &msg)
+{
+       std::string s;
+       char num[4];
+       unsigned stat = msg.tx_status;
+
+       if (stat)
+               s += "Tx";
+       if (stat & CEC_TX_STATUS_OK)
+               s += ", OK";
+       if (stat & CEC_TX_STATUS_ARB_LOST) {
+               sprintf(num, "%u", msg.tx_arb_lost_cnt);
+               s += ", Arbitration Lost";
+               if (msg.tx_arb_lost_cnt)
+                       s += " (" + std::string(num) + ")";
+       }
+       if (stat & CEC_TX_STATUS_NACK) {
+               sprintf(num, "%u", msg.tx_nack_cnt);
+               s += ", Not Acknowledged";
+               if (msg.tx_nack_cnt)
+                       s += " (" + std::string(num) + ")";
+       }
+       if (stat & CEC_TX_STATUS_LOW_DRIVE) {
+               sprintf(num, "%u", msg.tx_low_drive_cnt);
+               s += ", Low Drive";
+               if (msg.tx_low_drive_cnt)
+                       s += " (" + std::string(num) + ")";
+       }
+       if (stat & CEC_TX_STATUS_ERROR) {
+               sprintf(num, "%u", msg.tx_error_cnt);
+               s += ", Error";
+               if (msg.tx_error_cnt)
+                       s += " (" + std::string(num) + ")";
+       }
+       if (stat & CEC_TX_STATUS_MAX_RETRIES)
+               s += ", Max Retries";
+       return s;
+}
+
+static std::string rx_status2s(unsigned stat)
+{
+       std::string s;
+
+       if (stat)
+               s += "Rx";
+       if (stat & CEC_RX_STATUS_OK)
+               s += ", OK";
+       if (stat & CEC_RX_STATUS_TIMEOUT)
+               s += ", Timeout";
+       if (stat & CEC_RX_STATUS_FEATURE_ABORT)
+               s += ", Feature Abort";
+       return s;
+}
+
+std::string status2s(const struct cec_msg &msg)
+{
+       std::string s;
+
+       if (msg.tx_status)
+               s = tx_status2s(msg);
+       if (msg.rx_status) {
+               if (!s.empty())
+                       s += ", ";
+               s += rx_status2s(msg.rx_status);
+       }
+       return s;
+}
+
 void cec_driver_info(const struct cec_caps &caps,
                     const struct cec_log_addrs &laddrs, __u16 phys_addr)
 {
diff --git a/utils/common/cec-info.h b/utils/common/cec-info.h
index 18f2b94a1c24..a086ece042d0 100644
--- a/utils/common/cec-info.h
+++ b/utils/common/cec-info.h
@@ -21,6 +21,7 @@ const char *vendor2s(unsigned vendor);
 std::string all_dev_types2s(unsigned types);
 std::string rc_src_prof2s(unsigned prof, const std::string &prefix);
 std::string dev_feat2s(unsigned feat, const std::string &prefix);
+std::string status2s(const struct cec_msg &msg);
 
 void cec_driver_info(const struct cec_caps &caps,
                     const struct cec_log_addrs &laddrs, __u16 phys_addr);
diff --git a/utils/common/cec-log.cpp b/utils/common/cec-log.cpp
index b115449e29de..9ac59431a677 100644
--- a/utils/common/cec-log.cpp
+++ b/utils/common/cec-log.cpp
@@ -12,80 +12,13 @@
 #include <string>
 #include <linux/cec-funcs.h>
 #include "cec-htng-funcs.h"
+#include "cec-info.h"
 
 #define CEC_MAX_ARGS 16
 
 #define xstr(s) str(s)
 #define str(s) #s
 
-static std::string tx_status2s(const struct cec_msg &msg)
-{
-       std::string s;
-       char num[4];
-       unsigned stat = msg.tx_status;
-
-       if (stat)
-               s += "Tx";
-       if (stat & CEC_TX_STATUS_OK)
-               s += ", OK";
-       if (stat & CEC_TX_STATUS_ARB_LOST) {
-               sprintf(num, "%u", msg.tx_arb_lost_cnt);
-               s += ", Arbitration Lost";
-               if (msg.tx_arb_lost_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_NACK) {
-               sprintf(num, "%u", msg.tx_nack_cnt);
-               s += ", Not Acknowledged";
-               if (msg.tx_nack_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_LOW_DRIVE) {
-               sprintf(num, "%u", msg.tx_low_drive_cnt);
-               s += ", Low Drive";
-               if (msg.tx_low_drive_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_ERROR) {
-               sprintf(num, "%u", msg.tx_error_cnt);
-               s += ", Error";
-               if (msg.tx_error_cnt)
-                       s += " (" + std::string(num) + ")";
-       }
-       if (stat & CEC_TX_STATUS_MAX_RETRIES)
-               s += ", Max Retries";
-       return s;
-}
-
-static std::string rx_status2s(unsigned stat)
-{
-       std::string s;
-
-       if (stat)
-               s += "Rx";
-       if (stat & CEC_RX_STATUS_OK)
-               s += ", OK";
-       if (stat & CEC_RX_STATUS_TIMEOUT)
-               s += ", Timeout";
-       if (stat & CEC_RX_STATUS_FEATURE_ABORT)
-               s += ", Feature Abort";
-       return s;
-}
-
-static std::string status2s(const struct cec_msg &msg)
-{
-       std::string s;
-
-       if (msg.tx_status)
-               s = tx_status2s(msg);
-       if (msg.rx_status) {
-               if (!s.empty())
-                       s += ", ";
-               s += rx_status2s(msg.rx_status);
-       }
-       return s;
-}
-
 struct cec_enum_values {
        const char *type_name;
        __u8 value;

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

Reply via email to