Skip to contentSkip to conversation

cec: One Touch Record tests

PATCH New Deborah Brouwer 1 participant 3 messages Jun 30, 2021 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

v7 cover cec: One Touch Record tests

This is part of an Outreachy project to expand the testing of One Touch Record messages as handled by CEC adapters.

Changes since v6:
Patch 1/2: cec: expand One Touch Record tests
- assign primary device type to work for multiple logical addresses
- send primary device type earlier so other tests can rely on it Patch 2/2 cec: add One Touch Record Standby tests
- no change

Changes since v5:
Patch 1/2: cec: expand One Touch Record tests
- add comment to explain why initiator sends primary device type in the Record TV Screen test
- use array when follower gets remote primary device type
- use logical address to find the initiator's type and use primary device type only as an additional check
- check digital service broadcast system operands for channel service_id_method as well as digital service id
- check channel number format operands
Patch 2/2 cec: add One Touch Record Standby tests
- replace opcode argument with bool active_source
- set active source before sending standby command
- make "me" the active source when remote is inactive
- rename follower node state to "record_received_standby"
- set record_receive_standby in enter_standby and exit_standby

Changes since v4:
Patch 1/3: cec-follower: use log_addr_type to get local device type
- no change
Patch 2/3: cec: expand One Touch Record tests
- add comment to explain 10s timeout
- rephrase comment explaining rec_status_is_a_valid_error_status()
- use fail_on_test when checking source in Record TV Screen
- add comments to explain origin of digital services/analog channels
- reduce Record On tests, there is only one from each broadcast system
- add 10s timeout to Record Off
- keep newline in struct node in follower
- If the follower does not emulate a channel/service return a Record Status error instead of Feature Abort with Invalid Operand
- use digital_get_service_idx to check digital service
- add helper functions that check only validity of operands
- add helper function that checks exact matches for analog channels Patch 3/3 cec: add One Touch Record Standby tests
- no change

Changes since v3:
Patch 1/3: cec-follower: use log_addr_type to get local device type
- new patch
Patch 2/3: cec: expand One Touch Record tests
- this patch combines the previously separate patches for One Touch Record TV Screen and On/Off tests
- accurately check if the initiator is a recording device
- add digital service and analog service validation
- add invalid operand tests
- create a new helper function to send invalid record on operands without the 10s reply timeout
- always require feature abort in response to an invalid operand Patch 3/3 cec: add One Touch Record Standby tests
- no change

Changes since v2:
Patch 1/3 cec: expand One Touch Record TV Screen test:
- replace numbers with corresponding defines

Patch 2/3 cec: expand One Touch Record On/Off tests
- rename commit to reflect expanded scope of tests
- increase msg timeout for reply to 10s
- rename helper function and invert return value
- use primary device type to identify remote follower
- use logical address type to identify remote initiator
- limit range of accepted external plug numbers to 6
- disallow external physical address source
- keep track of whether the device is recording
- add additional invalid tests

Patch 3/3 cec: add One Touch Record Standby tests
- new patch

Changes since v1:
Patch 1/2 cec: expand One Touch Record TV Screen test:
- add space after 'switch'
- add "return" before fail
- check analog broadcast type and broadcast system operand
- add a comment when follower ignores message

Patch 2/2 cec: expand One Touch Record On test
- new patch

Deborah Brouwer (2):
cec: expand One Touch Record tests
cec: add One Touch Record Standby tests

 utils/cec-compliance/cec-compliance.cpp |   7 +-
 utils/cec-compliance/cec-compliance.h   |   1 +
 utils/cec-compliance/cec-test-power.cpp |  62 +++++
 utils/cec-compliance/cec-test.cpp       | 335 ++++++++++++++++++++++--
 utils/cec-follower/cec-follower.cpp     |   2 +
 utils/cec-follower/cec-follower.h       |   4 +
 utils/cec-follower/cec-processing.cpp   |  18 +-
 utils/cec-follower/cec-tuner.cpp        | 150 +++++++++--
 8 files changed, 529 insertions(+), 50 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v7 1/2 cec: expand One Touch Record tests

Expand the One Touch Record tests so that the follower and initiator know their local and remote device types and respond accordingly. Send Record TV Screen and check that Record On source replies are valid. Send Record On source messages and check that Record Status replies are valid. Send Record Off and check that the recording terminates.

---
 utils/cec-compliance/cec-compliance.cpp |   7 +-
 utils/cec-compliance/cec-compliance.h   |   1 +
 utils/cec-compliance/cec-test.cpp       | 335 ++++++++++++++++++++++--
 utils/cec-follower/cec-follower.cpp     |   1 +
 utils/cec-follower/cec-follower.h       |   2 +
 utils/cec-follower/cec-processing.cpp   |   4 +-
 utils/cec-follower/cec-tuner.cpp        | 141 ++++++++--
 7 files changed, 442 insertions(+), 49 deletions(-)
utils/cec-compliance/cec-compliance.cpp +4 -3
index c04904c2..25931259 100644
@@ -1264,9 +1264,10 @@ int main(int argc, char **argv)
 		remote_la_mask = 1 << remote_la;
 
 	if (test_remote) {
-		for (unsigned from = 0; from <= 15; from++) {
-			if (!(node.adap_la_mask & (1 << from)))
-				continue;
+		for (unsigned i = 0; i < node.num_log_addrs; i++) {
+			unsigned from = node.log_addr[i];
+			node.prim_devtype = laddrs.primary_device_type[i];
+
 			for (unsigned to = 0; to <= 15; to++)
 				if (!(node.adap_la_mask & (1 << to)) &&
 				    (remote_la_mask & (1 << to)))
utils/cec-compliance/cec-compliance.h +1 -0
index 818181ab..41e2d63d 100644
@@ -166,6 +166,7 @@ struct node {
 	struct remote remote[16];
 	__u16 phys_addr;
 	bool in_standby;
+	__u8 prim_devtype;
 };
 
 struct remote_subtest {
utils/cec-compliance/cec-test.cpp +306 -29

398 lines not on this page · raw message

utils/cec-follower/cec-follower.cpp +1 -0
index ff47d698..482192e7 100644
@@ -317,6 +317,7 @@ void state_init(struct node &node)
 	node.state.deck_report_changes_to = 0;
 	node.state.deck_state = CEC_OP_DECK_INFO_STOP;
 	node.state.deck_skip_start = 0;
+	node.state.one_touch_record_on = false;
 	tuner_dev_info_init(&node.state);
 	node.state.last_aud_rate_rx_ts = 0;
 }
utils/cec-follower/cec-follower.h +2 -0
index 343ae998..8dfbd39f 100644
@@ -53,6 +53,7 @@ struct state {
 	__u8 deck_report_changes_to;
 	__u8 deck_state;
 	__u64 deck_skip_start;
+	bool one_touch_record_on;
 	time_t toggle_power_status;
 	__u64 last_aud_rate_rx_ts;
 };
@@ -62,6 +63,7 @@ struct node {
 	const char *device;
 	unsigned caps;
 	unsigned available_log_addrs;
+	__u8 remote_prim_devtype[15];
 	unsigned adap_la_mask;
 	unsigned remote_la_mask;
 	__u16 remote_phys_addr[15];
utils/cec-follower/cec-processing.cpp +3 -1
index 6db3f98e..e1a71d6c 100644
@@ -396,8 +396,10 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me, __u8
 		__u8 prim_dev_type;
 
 		cec_ops_report_physical_addr(&msg, &phys_addr, &prim_dev_type);
-		if (from < 15)
+		if (from < 15) {
 			node->remote_phys_addr[from] = phys_addr;
+			node->remote_prim_devtype[from] = prim_dev_type;
+		}
 		return;
 	}
 
utils/cec-follower/cec-tuner.cpp +125 -16

175 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH v7 2/2 cec: add One Touch Record Standby tests

In reply to Deborah Brouwer

Check that the recording device ignores a Standby message while it is recording. When the recording is finished, check that the recording device enters standby unless the recording device is the active source.

---
 utils/cec-compliance/cec-test-power.cpp | 62 +++++++++++++++++++++++++
 utils/cec-follower/cec-follower.cpp     |  1 +
 utils/cec-follower/cec-follower.h       |  2 +
 utils/cec-follower/cec-processing.cpp   | 14 +++++-
 utils/cec-follower/cec-tuner.cpp        |  9 ++++
 5 files changed, 87 insertions(+), 1 deletion(-)
utils/cec-compliance/cec-test-power.cpp +62 -0
index b675bfc4..f23d0414 100644
@@ -677,6 +677,66 @@ static int standby_resume_wakeup_deck_play(struct node *node, unsigned me, unsig
 	return standby_resume_wakeup_deck(node, me, la, interactive, CEC_OP_PLAY_MODE_PLAY_FWD);
 }
 
+static int standby_record(struct node *node, unsigned me, unsigned la, bool interactive, bool active_source)
+{
+	struct cec_msg msg;
+	__u8 rec_status;
+	unsigned unresponsive_time = 0;
+
+	cec_msg_init(&msg, me, la);
+	cec_msg_record_on_own(&msg);
+	msg.reply = CEC_MSG_RECORD_STATUS;
+	fail_on_test(!transmit_timeout(node, &msg, 10000));
+	if (timed_out_or_abort(&msg))
+		return OK_NOT_SUPPORTED;
+	cec_ops_record_status(&msg, &rec_status);
+	fail_on_test(rec_status != CEC_OP_RECORD_STATUS_CUR_SRC &&
+	             rec_status != CEC_OP_RECORD_STATUS_ALREADY_RECORDING);
+
+	cec_msg_init(&msg, me, la);
+	if (active_source)
+		cec_msg_active_source(&msg, node->remote[la].phys_addr);
+	else
+		cec_msg_active_source(&msg, me);
+	fail_on_test(!transmit_timeout(node, &msg));
+
+	cec_msg_init(&msg, me, la);
+	cec_msg_standby(&msg);
+	fail_on_test(!transmit_timeout(node, &msg));
+	/* Standby should not interrupt the recording. */
+	fail_on_test(!poll_stable_power_status(node, me, la, CEC_OP_POWER_STATUS_ON, unresponsive_time));
+
+	cec_msg_init(&msg, me, la);
+	cec_msg_record_off(&msg, false);
+	fail_on_test(!transmit_timeout(node, &msg));
+
+	/* When the recording stops, recorder should standby unless it is the active source. */
+	if (active_source) {
+		fail_on_test(!poll_stable_power_status(node, me, la, CEC_OP_POWER_STATUS_ON, unresponsive_time));
+	} else {
+		fail_on_test(!poll_stable_power_status(node, me, la, CEC_OP_POWER_STATUS_STANDBY, unresponsive_time));
+		fail_on_test(interactive && !question("Is the device in standby?"));
+		node->remote[la].in_standby = true;
+
+		int ret = standby_resume_wakeup(node, me, la, interactive);
+		if (ret)
+			return ret;
+		node->remote[la].in_standby = false;
+	}
+
+	return OK;
+}
+
+static int standby_record_active_source(struct node *node, unsigned me, unsigned la, bool interactive)
+{
+	return standby_record(node, me, la, interactive, true);
+}
+
+static int standby_record_inactive_source(struct node *node, unsigned me, unsigned la, bool interactive)
+{
+	return standby_record(node, me, la, interactive, false);
+}
+
 const vec_remote_subtests 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 },
@@ -697,4 +757,6 @@ const vec_remote_subtests standby_resume_subtests{
 	{ "Power State Transitions", CEC_LOG_ADDR_MASK_TV, power_state_transitions, false, true },
 	{ "Deck Eject Standby Resume", CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD, standby_resume_wakeup_deck_eject },
 	{ "Deck Play Standby Resume", CEC_LOG_ADDR_MASK_PLAYBACK | CEC_LOG_ADDR_MASK_RECORD, standby_resume_wakeup_deck_play },
+	{ "Record Standby Active Source", CEC_LOG_ADDR_MASK_RECORD | CEC_LOG_ADDR_MASK_BACKUP, standby_record_active_source },
+	{ "Record Standby Inactive Source", CEC_LOG_ADDR_MASK_RECORD | CEC_LOG_ADDR_MASK_BACKUP, standby_record_inactive_source },
 };
utils/cec-follower/cec-follower.cpp +1 -0
index 482192e7..2816fb85 100644
@@ -318,6 +318,7 @@ void state_init(struct node &node)
 	node.state.deck_state = CEC_OP_DECK_INFO_STOP;
 	node.state.deck_skip_start = 0;
 	node.state.one_touch_record_on = false;
+	node.state.record_received_standby = false;
 	tuner_dev_info_init(&node.state);
 	node.state.last_aud_rate_rx_ts = 0;
 }
utils/cec-follower/cec-follower.h +2 -0
index 8dfbd39f..833dec5e 100644
@@ -54,6 +54,7 @@ struct state {
 	__u8 deck_state;
 	__u64 deck_skip_start;
 	bool one_touch_record_on;
+	bool record_received_standby;
 	time_t toggle_power_status;
 	__u64 last_aud_rate_rx_ts;
 };
@@ -230,5 +231,6 @@ void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, uns
 void reply_feature_abort(struct node *node, struct cec_msg *msg,
 			 __u8 reason = CEC_OP_ABORT_UNRECOGNIZED_OP);
 void testProcessing(struct node *node, bool wallclock);
+bool enter_standby(struct node *node);
 
 #endif
utils/cec-follower/cec-processing.cpp +13 -1
index e1a71d6c..32375966 100644
@@ -146,6 +146,9 @@ void reply_feature_abort(struct node *node, struct cec_msg *msg, __u8 reason)
 
 static bool exit_standby(struct node *node)
 {
+	/* Cancel any standby request that was pending. */
+	node->state.record_received_standby = false;
+
 	if (node->state.power_status == CEC_OP_POWER_STATUS_STANDBY ||
 	    node->state.power_status == CEC_OP_POWER_STATUS_TO_STANDBY) {
 		node->state.old_power_status = node->state.power_status;
@@ -157,14 +160,23 @@ static bool exit_standby(struct node *node)
 	return false;
 }
 
-static bool enter_standby(struct node *node)
+bool enter_standby(struct node *node)
 {
 	if (node->state.power_status == CEC_OP_POWER_STATUS_ON ||
 	    node->state.power_status == CEC_OP_POWER_STATUS_TO_ON) {
+		/*
+		 * Standby should not interrupt a recording in progress, but
+		 * remember to go to standby once the recording is finished.
+		 */
+		if (node->state.one_touch_record_on) {
+			node->state.record_received_standby = true;
+			return false;
+		}
 		node->state.old_power_status = node->state.power_status;
 		node->state.power_status = CEC_OP_POWER_STATUS_STANDBY;
 		node->state.power_status_changed_time = time(nullptr);
 		node->state.deck_skip_start = 0;
+		node->state.record_received_standby = false;
 		dev_info("Changing state to standby\n");
 		return true;
 	}
utils/cec-follower/cec-tuner.cpp +9 -0
index 13cf6d20..e1d8b8fc 100644
@@ -724,6 +724,15 @@ void process_tuner_record_timer_msgs(struct node *node, struct cec_msg &msg, uns
 		cec_msg_record_status(&msg, CEC_OP_RECORD_STATUS_TERMINATED_OK);
 		transmit(node, &msg);
 		node->state.one_touch_record_on = false;
+		/*
+		 * If standby was received during recording, enter standby when the
+		 * recording is finished unless recording device is the active source.
+		 */
+		if (node->state.record_received_standby) {
+			if (node->phys_addr != node->state.active_source_pa)
+				enter_standby(node);
+			node->state.record_received_standby = false;
+		}
 		return;
 	case CEC_MSG_RECORD_STATUS:
 		return;
Signature · 1 line
2.25.1