Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f98da96 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

[media] cec: ignore messages that we initiated



Some CEC adapters will receive messages that they initiated. Add a
check that will ignore such messages.

Most hardware behaves correctly in this respect, but I have seen
adapters that don't, so just filter this out in the framework.

Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 7febb418
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -869,6 +869,21 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
	if (WARN_ON(!msg->len || msg->len > CEC_MAX_MSG_SIZE))
	if (WARN_ON(!msg->len || msg->len > CEC_MAX_MSG_SIZE))
		return;
		return;


	/*
	 * Some CEC adapters will receive the messages that they transmitted.
	 * This test filters out those messages by checking if we are the
	 * initiator, and just returning in that case.
	 *
	 * Note that this won't work if this is an Unregistered device.
	 *
	 * It is bad practice if the hardware receives the message that it
	 * transmitted and luckily most CEC adapters behave correctly in this
	 * respect.
	 */
	if (msg_init != CEC_LOG_ADDR_UNREGISTERED &&
	    cec_has_log_addr(adap, msg_init))
		return;

	msg->rx_ts = ktime_get_ns();
	msg->rx_ts = ktime_get_ns();
	msg->rx_status = CEC_RX_STATUS_OK;
	msg->rx_status = CEC_RX_STATUS_OK;
	msg->sequence = msg->reply = msg->timeout = 0;
	msg->sequence = msg->reply = msg->timeout = 0;