v4l-utils: switch remote_subtest arrays to vector
PATCH v2 1/1 v4l-utils: switch remote_subtest arrays to vector
Easier to read and allows removing some boilerplate code. Only a moderate size increase.
Ran through git clang-format
Signed-off-by Rosen Penev <[email protected]>
---
v2: added using statement and removed auto&&
utils/cec-compliance/cec-compliance.h | 28 ++-- utils/cec-compliance/cec-test-audio.cpp | 171 ++++++++++++---------- utils/cec-compliance/cec-test-power.cpp | 17 +-- utils/cec-compliance/cec-test.cpp | 182 +++++++----------------- 4 files changed, 170 insertions(+), 228 deletions(-)
utils/cec-compliance/cec-compliance.h +12 -16
@@ -19,6 +19,8 @@#include <cec-info.h> +#include <vector> +#define TAG_AUDIO_RATE_CONTROL 1#define TAG_ARC_CONTROL (1 << 1)#define TAG_CAP_DISCOVERY_CONTROL (1 << 2)
@@ -174,6 +176,8 @@ struct remote_subtest {bool for_cec20; }; +using stvec = std::vector<remote_subtest>; +#define OK 0#define FAIL 1#define OK_PRESUMED 2
@@ -456,25 +460,17 @@ void testRemote(struct node *node, unsigned me, unsigned la, unsigned test_tags, bool interactive);// cec-test-audio.cpp -extern struct remote_subtest sac_subtests[]; -extern const unsigned sac_subtests_size; -extern struct remote_subtest dal_subtests[]; -extern const unsigned dal_subtests_size; -extern struct remote_subtest arc_subtests[]; -extern const unsigned arc_subtests_size; -extern struct remote_subtest audio_rate_ctl_subtests[]; -extern const unsigned audio_rate_ctl_subtests_size; +extern const stvec sac_subtests; +extern const stvec dal_subtests; +extern const stvec arc_subtests; +extern const stvec audio_rate_ctl_subtests;// cec-test-power.cpp bool util_interactive_ensure_power_state (struct node *node,unsigned me,unsigned la,bool interactive,__u8 target_pwr); -extern struct remote_subtest standby_subtests[]; -extern const unsigned standby_subtests_size; -extern struct remote_subtest one_touch_play_subtests[]; -extern const unsigned one_touch_play_subtests_size; -extern struct remote_subtest power_status_subtests[]; -extern const unsigned power_status_subtests_size; -extern struct remote_subtest standby_resume_subtests[]; -extern const unsigned standby_resume_subtests_size; +extern const stvec standby_subtests; +extern const stvec one_touch_play_subtests; +extern const stvec power_status_subtests; +extern const stvec standby_resume_subtests;#endif
utils/cec-compliance/cec-test-audio.cpp +99 -72
205 lines not on this page · raw message
utils/cec-compliance/cec-test-power.cpp +5 -12
@@ -6,6 +6,7 @@ #include <cerrno> #include <ctime> #include <string> +#include <vector> #include <sys/ioctl.h> #include <unistd.h>
@@ -95,14 +96,11 @@ static int power_status_report(struct node *node, unsigned me, unsigned la, bool return OK_PRESUMED; } -struct remote_subtest power_status_subtests[] = { +const stvec power_status_subtests{ { "Give Device Power Status", CEC_LOG_ADDR_MASK_ALL, power_status_give }, { "Report Device Power Status", CEC_LOG_ADDR_MASK_ALL, power_status_report }, }; -const unsigned power_status_subtests_size = ARRAY_SIZE(power_status_subtests); - - /* One Touch Play */ static int one_touch_play_view_on(struct node *node, unsigned me, unsigned la, bool interactive,
@@ -233,7 +231,7 @@ static int one_touch_play_req_active_source(struct node *node, unsigned me, unsi return 0; } -struct remote_subtest one_touch_play_subtests[] = { +const stvec one_touch_play_subtests{ { "Image View On", CEC_LOG_ADDR_MASK_TV, one_touch_play_image_view_on }, { "Text View On", CEC_LOG_ADDR_MASK_TV, one_touch_play_text_view_on }, { "Wakeup on Image View On", CEC_LOG_ADDR_MASK_TV, one_touch_play_image_view_on_wakeup },
@@ -243,9 +241,6 @@ struct remote_subtest one_touch_play_subtests[] = { { "Active Source and Request Active Source", CEC_LOG_ADDR_MASK_ALL, one_touch_play_req_active_source }, }; -const unsigned one_touch_play_subtests_size = ARRAY_SIZE(one_touch_play_subtests); - - /* Standby / Resume */ /* The default sleep time between power status requests. */
@@ -638,7 +633,7 @@ static int power_state_transitions(struct node *node, unsigned me, unsigned la, return 0; } -struct remote_subtest standby_resume_subtests[] = { +const stvec standby_resume_subtests{ { "Standby", CEC_LOG_ADDR_MASK_ALL, standby_resume_standby }, { "Repeated Standby message does not wake up", CEC_LOG_ADDR_MASK_ALL, standby_resume_standby_toggle }, { "Standby: Feature aborts unknown messages", CEC_LOG_ADDR_MASK_ALL, core_unknown, true },
@@ -652,10 +647,8 @@ struct remote_subtest standby_resume_subtests[] = { { "Standby: Get Menu Language", CEC_LOG_ADDR_MASK_ALL, system_info_get_menu_lang, true }, { "Standby: Give Device Features", CEC_LOG_ADDR_MASK_ALL, system_info_give_features, true }, { "No wakeup on Active Source", CEC_LOG_ADDR_MASK_ALL, standby_resume_active_source_nowake }, - { "Wake up", CEC_LOG_ADDR_MASK_ALL, standby_resume_wakeup}, + { "Wake up", CEC_LOG_ADDR_MASK_ALL, standby_resume_wakeup }, { "Wake up TV on Image View On", CEC_LOG_ADDR_MASK_TV, standby_resume_wakeup_image_view_on }, { "Wake up TV on Text View On", CEC_LOG_ADDR_MASK_TV, standby_resume_wakeup_text_view_on }, { "Power State Transitions", CEC_LOG_ADDR_MASK_TV, power_state_transitions, false, true }, }; - -const unsigned standby_resume_subtests_size = ARRAY_SIZE(standby_resume_subtests);
utils/cec-compliance/cec-test.cpp +54 -128
364 lines not on this page · raw message
Signature · 1 line
2.30.2