aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Fjeldtvedt <jaffe1@gmail.com>2016-07-19 13:45:31 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2016-07-19 13:46:42 +0200
commitcd633bb91c375dd333b5ac0e90c1d9e8b5c07fb8 (patch)
tree8f7183387f0fdc9d6a76acae90dae0e64456b6fe
parentb2493c201c0972bc9b47419bff9476cca377d1d0 (diff)
cec-compliance: send release after presses in SAC tests
Send User Control Released following each User Control Pressed. Since we want to send the release right (or shortly) after the press, we need to manually receive the messages to see if a Report Audio Status was received. Signed-off-by: Johan Fjeldtvedt <jaffe1@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--utils/cec-compliance/cec-audio.cpp96
1 files changed, 51 insertions, 45 deletions
diff --git a/utils/cec-compliance/cec-audio.cpp b/utils/cec-compliance/cec-audio.cpp
index f90a246f..f393712e 100644
--- a/utils/cec-compliance/cec-audio.cpp
+++ b/utils/cec-compliance/cec-audio.cpp
@@ -128,6 +128,33 @@ static bool pa_is_upstream_from(__u16 pa1, __u16 pa2)
return false;
}
+static bool util_receive(struct node *node, unsigned la, struct cec_msg *msg,
+ __u8 sent_msg, __u8 reply1, __u8 reply2 = 0)
+{
+ while (1) {
+ memset(msg, 0, sizeof(*msg));
+ msg->timeout = 1;
+ if (doioctl(node, CEC_RECEIVE, msg))
+ break;
+ if (cec_msg_initiator(msg) != la)
+ continue;
+
+ if (msg->msg[1] == CEC_MSG_FEATURE_ABORT) {
+ __u8 reason, abort_msg;
+
+ cec_ops_feature_abort(msg, &abort_msg, &reason);
+ if (abort_msg != sent_msg)
+ continue;
+ return true;
+ }
+
+ if (msg->msg[1] == reply1 || (reply2 && msg->msg[1] == reply2))
+ return true;
+ }
+
+ return false;
+}
+
static int arc_initiate_tx(struct node *node, unsigned me, unsigned la, bool interactive)
{
/* Check if we are upstream from the device. If we are, then the device is
@@ -137,7 +164,6 @@ static int arc_initiate_tx(struct node *node, unsigned me, unsigned la, bool int
struct cec_msg msg = {};
bool got_response = false;
- __u8 abort_msg, reason = 0;
/* TODO: CEC framework should perhaps support more than one possible
reply opcode for a message.
@@ -157,33 +183,13 @@ static int arc_initiate_tx(struct node *node, unsigned me, unsigned la, bool int
cec_msg_init(&msg, me, la);
cec_msg_initiate_arc(&msg, false);
fail_on_test(!transmit_timeout(node, &msg));
- /* The transmit_timeout call will block for one second. After that we can
- loop over the received messages and see if any of them match as a possible
- reply to Initiate ARC. */
- do {
- memset(&msg, 0, sizeof(msg));
- msg.timeout = 1;
- if (doioctl(node, CEC_RECEIVE, &msg))
- break;
- if (cec_msg_initiator(&msg) != la)
- continue;
-
- switch (msg.msg[1]) {
- case CEC_MSG_FEATURE_ABORT:
- cec_ops_feature_abort(&msg, &abort_msg, &reason);
- if (reason != CEC_MSG_INITIATE_ARC)
- continue;
- case CEC_MSG_REPORT_ARC_INITIATED:
- case CEC_MSG_REPORT_ARC_TERMINATED:
- got_response = true;
- break;
- }
- } while (!got_response);
+ got_response = util_receive(node, la, &msg, CEC_MSG_INITIATE_ARC,
+ CEC_MSG_REPORT_ARC_INITIATED, CEC_MSG_REPORT_ARC_TERMINATED);
mode = CEC_MODE_INITIATOR;
doioctl(node, CEC_S_MODE, &mode);
if (!got_response || (got_response && cec_msg_status_is_abort(&msg) &&
- reason == CEC_OP_ABORT_UNRECOGNIZED_OP)) {
+ abort_reason(&msg) == CEC_OP_ABORT_UNRECOGNIZED_OP)) {
fail_on_test_v2(node->remote[la].cec_version, node->remote[la].has_arc_tx);
return NOTSUPPORTED;
}
@@ -549,26 +555,35 @@ static int sac_util_send_user_control_press(struct node *node, unsigned me, unsi
It is recommended for devices to not send Report Audio Status back
more often than once every 500ms. We therefore sleep a second before
each User Control Pressed is sent. */
+ __u32 mode = CEC_MODE_INITIATOR | CEC_MODE_FOLLOWER;
+ bool got_response;
+
sleep(1);
+ doioctl(node, CEC_S_MODE, &mode);
cec_msg_init(&msg, me, la);
rc_press.ui_cmd = ui_cmd;
cec_msg_user_control_pressed(&msg, &rc_press);
- if (node->remote[la].cec_version >= CEC_OP_CEC_VERSION_2_0 &&
- la == CEC_LOG_ADDR_AUDIOSYSTEM) {
- msg.reply = CEC_MSG_REPORT_AUDIO_STATUS;
- fail_on_test(!transmit_timeout(node, &msg));
- fail_on_test(timed_out_or_abort(&msg));
- cec_ops_report_audio_status(&msg, &node->remote[la].mute, &node->remote[la].volume);
- return 0;
- }
+ fail_on_test(!transmit(node, &msg));
+ cec_msg_init(&msg, me, la);
+ cec_msg_user_control_released(&msg);
fail_on_test(!transmit_timeout(node, &msg));
+ got_response = util_receive(node, la, &msg, CEC_MSG_USER_CONTROL_PRESSED, CEC_MSG_REPORT_AUDIO_STATUS);
+ mode = CEC_MODE_INITIATOR;
+ doioctl(node, CEC_S_MODE, &mode);
+
+ fail_on_test_v2(node->remote[la].cec_version, !got_response &&
+ cec_has_audiosystem(1 << la));
fail_on_test_v2(node->remote[la].cec_version, cec_msg_status_is_abort(&msg) &&
(is_tv(la, node->remote[la].prim_type) || cec_has_audiosystem(1 << la)));
if (cec_msg_status_is_abort(&msg) && !node->remote[la].has_sys_audio_mode_req)
return NOTSUPPORTED;
fail_on_test(cec_msg_status_is_abort(&msg));
+ if (got_response) {
+ cec_ops_report_audio_status(&msg, &node->remote[la].mute, &node->remote[la].volume);
+ return 0;
+ }
- return 0;
+ return PRESUMED_OK;
}
static int sac_user_control_press_vol_up(struct node *node, unsigned me, unsigned la, bool interactive)
@@ -582,10 +597,7 @@ static int sac_user_control_press_vol_up(struct node *node, unsigned me, unsigne
la == CEC_LOG_ADDR_AUDIOSYSTEM &&
old_volume < 100 && node->remote[la].volume <= old_volume);
- if (node->remote[la].cec_version >= CEC_OP_CEC_VERSION_2_0)
- return 0;
- else
- return PRESUMED_OK;
+ return 0;
}
static int sac_user_control_press_vol_down(struct node *node, unsigned me, unsigned la, bool interactive)
@@ -599,10 +611,7 @@ static int sac_user_control_press_vol_down(struct node *node, unsigned me, unsig
la == CEC_LOG_ADDR_AUDIOSYSTEM &&
old_volume > 0 && node->remote[la].volume >= old_volume);
- if (node->remote[la].cec_version >= CEC_OP_CEC_VERSION_2_0)
- return 0;
- else
- return PRESUMED_OK;
+ return 0;
}
static int sac_user_control_press_mute(struct node *node, unsigned me, unsigned la, bool interactive)
@@ -616,10 +625,7 @@ static int sac_user_control_press_mute(struct node *node, unsigned me, unsigned
la == CEC_LOG_ADDR_AUDIOSYSTEM &&
node->remote[la].mute == old_mute);
- if (node->remote[la].cec_version >= CEC_OP_CEC_VERSION_2_0)
- return 0;
- else
- return PRESUMED_OK;
+ return 0;
}
static int sac_user_control_release(struct node *node, unsigned me, unsigned la, bool interactive)

Privacy Policy